net.walend.digraph
Interface UEDigraph

All Superinterfaces:
Digraph, HasState
All Known Subinterfaces:
MutableUEDigraph, MutableUEPath, UEPath
All Known Implementing Classes:
AbstractHashUEDigraph, AbstractListUEPath, AbstractMatrixUEDigraph, MutableHashUEDigraph, MutableListUEPath, MutableMatrixUEDigraph

public interface UEDigraph
extends Digraph

UEDigraph is an interface for representing directed graphs of nodes linked by zero or one edge. Each node and edge must be a unique Object in the digraph. Reusing edges and nodes may produce unpredictable results.

By default, this digraph uses equals() as the method to determine identity.

One could create a subclass of UEDigraph that will work with zero or more edges by extending this interface. I have not done that.

Direct implementations of UEDigraph should have a single constructor that takes a UEDigraph as a parameter.

Since:
20010612
Author:
David Walend dfw1@cornell.edu

Field Summary
static UEDigraph EMPTY
           
 
Method Summary
 boolean containsEdge(java.lang.Object edge)
          Returns true if edge exists in the digraph anywhere
 boolean containsEdge(java.lang.Object fromNode, java.lang.Object toNode, java.lang.Object edge)
          Returns true if edge links fromNode to toNode
 boolean containsEdges(java.util.Set edges)
           
 boolean containsUEDigraph(UEDigraph digraph)
          Returns true if digraph is a subgraph of this UEDigraph.
 EdgeIterator edgeIterator()
           
 java.lang.Object getEdge(java.lang.Object fromNode, java.lang.Object toNode)
          Returns null if no edge links fromNode to toNode
 java.util.Set getEdges()
           
 java.lang.Object getFromNode(java.lang.Object edge)
           
 java.util.Set getInboundEdges(java.lang.Object node)
          Returns the empty set if node has no inbound edges.
 java.util.Set getOutboundEdges(java.lang.Object node)
          Returns the empty set if node has no outbound edges.
 java.lang.Object getToNode(java.lang.Object edge)
           
 UEDigraph intersectWithUEDigraph(UEDigraph digraph)
          Returns a new digraph that is the intersection of this with digraph.
 boolean sameUEDigraphAs(UEDigraph digraph)
          Returns true if digraph is the same as this; that is, if this.containsUEDigraph(digraph) and digraph.containsUEDigraph(this).
 UEDigraph unionUEDigraph(UEDigraph digraph)
          Returns a new digraph that is the union of this with digraph.
 
Methods inherited from interface net.walend.digraph.Digraph
containsEdge, containsNode, containsNodes, countInboundEdges, countOutboundEdges, edgeCount, edgeNodeIterator, getFromNodes, getNodes, getToNodes, isEdgeFree, isEmpty, nodeCount, nodeIterator
 
Methods inherited from interface net.walend.collection.HasState
getPrincipleInterface, sameStateAs
 

Field Detail

EMPTY

public static final UEDigraph EMPTY
Method Detail

containsEdge

public boolean containsEdge(java.lang.Object fromNode,
                            java.lang.Object toNode,
                            java.lang.Object edge)
                     throws NodeMissingException
Returns true if edge links fromNode to toNode

Throws:
NodeMissingException - if either node is missing from the digraph.

containsEdge

public boolean containsEdge(java.lang.Object edge)
Returns true if edge exists in the digraph anywhere


getInboundEdges

public java.util.Set getInboundEdges(java.lang.Object node)
                              throws NodeMissingException
Returns the empty set if node has no inbound edges.

Throws:
NodeMissingException - if node is not in the digraph.

getOutboundEdges

public java.util.Set getOutboundEdges(java.lang.Object node)
                               throws NodeMissingException
Returns the empty set if node has no outbound edges.

Throws:
NodeMissingException - if node is not in the digraph.

getFromNode

public java.lang.Object getFromNode(java.lang.Object edge)
                             throws EdgeMissingException
Throws:
EdgeMissingException - if the edge is not in the digraph.

getToNode

public java.lang.Object getToNode(java.lang.Object edge)
                           throws EdgeMissingException
Throws:
EdgeMissingException - if the edge is not in the digraph.

getEdge

public java.lang.Object getEdge(java.lang.Object fromNode,
                                java.lang.Object toNode)
                         throws NodeMissingException
Returns null if no edge links fromNode to toNode

Throws:
NodeMissingException - if either node is missing from the digraph.

edgeIterator

public EdgeIterator edgeIterator()

getEdges

public java.util.Set getEdges()

containsEdges

public boolean containsEdges(java.util.Set edges)

containsUEDigraph

public boolean containsUEDigraph(UEDigraph digraph)
Returns true if digraph is a subgraph of this UEDigraph.


sameUEDigraphAs

public boolean sameUEDigraphAs(UEDigraph digraph)
Returns true if digraph is the same as this; that is, if this.containsUEDigraph(digraph) and digraph.containsUEDigraph(this).


intersectWithUEDigraph

public UEDigraph intersectWithUEDigraph(UEDigraph digraph)
Returns a new digraph that is the intersection of this with digraph. Implementations should generally return the same implementation of UEDigraph as they have themselves.


unionUEDigraph

public UEDigraph unionUEDigraph(UEDigraph digraph)
Returns a new digraph that is the union of this with digraph. Implementations should generally return the same implementation of UEDigraph as they are themselves. If the digraphs contain conflicting edges, then (unless you have a better rule) let digraph's edge win out.



Copyright (c) 2001, 2002, David Walend