net.walend.digraph
Interface GEDigraph

All Superinterfaces:
HasState
All Known Subinterfaces:
MutableGEDigraph
All Known Implementing Classes:
AbstractHashGEDigraph, MutableHashGEDigraph

public interface GEDigraph
extends HasState

GEDigraph is an interface for representing directed graphs of nodes linked by zero or one edge. Each node must be a unique Object in the digraph. Edges are not objects at all, and are represented simply by being present or not.

By default, this digraph uses equals() as the method to determine identity. Persistent versions may use hasSameIdentity() instead, for example.

Direct implementations of GEDigraph should have a single constructor that takes a GEDigraph as a parameter. Some implementations should provide a view of this GEDigraph, by implementing the net.walend.collection.View interface. Others should copy the parameter to produced an immutable GEDigraph.

Since:
20010812
Author:
David Walend

Field Summary
static GEDigraph EMPTY
           
 
Method Summary
 boolean containsEdge(java.lang.Object fromNode, java.lang.Object toNode)
          Returns true if the digraph contains any edge from fromNode to toNode
 boolean containsGEDigraph(GEDigraph digraph)
          Returns true if digraph is a subgraph of this GEDigraph.
 boolean containsNode(java.lang.Object node)
           
 boolean containsNodes(Set nodes)
           
 int countInboundEdges(java.lang.Object node)
           
 int countOutboundEdges(java.lang.Object node)
           
 int edgeCount()
           
 EdgeNodeIterator edgeNodeIterator()
          Returns an iterator that iterates across pairs of nodes that make edges.
 Set getFromNodes(java.lang.Object node)
          Returns the set of nodes that can reach this node by crossing one edge.
 Set getNodes()
           
 Set getToNodes(java.lang.Object node)
          Returns the set of nodes that can be reached from this node by crossing one edge.
 GEDigraph intersectWithGEDigraph(GEDigraph digraph)
          Returns a new digraph that is the intersection of this with digraph.
 boolean isEdgeFree()
          Returns true if this GEDigraph has no edges.
 boolean isEmpty()
           
 int nodeCount()
           
 java.util.Iterator nodeIterator()
          Implementations should explicitly state how they interpret nodeIterator()'s remove method.
 boolean sameGEDigraphAs(GEDigraph digraph)
          Returns true if digraph is the same as this; that is, if this.containsGEDigraph(digraph) and digraph.containsGEDigraph(this).
 GEDigraph unionGEDigraph(GEDigraph digraph)
          Returns a new digraph that is the union of this with digraph.
 
Methods inherited from interface net.walend.collection.HasState
getPrincipleInterface, sameStateAs
 

Field Detail

EMPTY

public static final GEDigraph EMPTY
Method Detail

nodeCount

public int nodeCount()

edgeCount

public int edgeCount()

isEmpty

public boolean isEmpty()

containsNode

public boolean containsNode(java.lang.Object node)

containsEdge

public boolean containsEdge(java.lang.Object fromNode,
                            java.lang.Object toNode)
                     throws NodeMissingException
Returns true if the digraph contains any edge from fromNode to toNode

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

countInboundEdges

public int countInboundEdges(java.lang.Object node)
                      throws NodeMissingException
Throws:
NodeMissingException - if node is not in the digraph.

countOutboundEdges

public int countOutboundEdges(java.lang.Object node)
                       throws NodeMissingException
Throws:
NodeMissingException - if node is not in the digraph.

getFromNodes

public Set getFromNodes(java.lang.Object node)
                 throws NodeMissingException
Returns the set of nodes that can reach this node by crossing one edge.

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

getToNodes

public Set getToNodes(java.lang.Object node)
               throws NodeMissingException
Returns the set of nodes that can be reached from this node by crossing one edge.

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

nodeIterator

public java.util.Iterator nodeIterator()
Implementations should explicitly state how they interpret nodeIterator()'s remove method. It should either throw an UnsupportedOperationException or cause a hidden side effect of removing edges.


edgeNodeIterator

public EdgeNodeIterator edgeNodeIterator()
Returns an iterator that iterates across pairs of nodes that make edges.


getNodes

public Set getNodes()

isEdgeFree

public boolean isEdgeFree()
Returns true if this GEDigraph has no edges.


containsNodes

public boolean containsNodes(Set nodes)

containsGEDigraph

public boolean containsGEDigraph(GEDigraph digraph)
Returns true if digraph is a subgraph of this GEDigraph.


sameGEDigraphAs

public boolean sameGEDigraphAs(GEDigraph digraph)
Returns true if digraph is the same as this; that is, if this.containsGEDigraph(digraph) and digraph.containsGEDigraph(this).


intersectWithGEDigraph

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


unionGEDigraph

public GEDigraph unionGEDigraph(GEDigraph digraph)
Returns a new digraph that is the union of this with digraph. Implementations should generally return the same implementation of GEDigraph 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) 2000, 2001, David Walend