Interface Graph

 All Known Subinterfaces:
DirectedGraph
 All Known Implementing Classes:
BasicDirectedGraph
,BasicGraph
public interface Graph
Represents a graph.A graph is a collection of nodes (verticies) connected by links called edges (arcs).
In most applications nodes of a graph represent the objects being modelled, and the edges represent the relationships between the objects. An example could be a polygon coverage in which one wishes to model a boundary sharing relationship. The following is an illustration.
In the above figure, the objects (nodes) are the polygons themselves, and the relationship (edges) between them is boundary sharing.
However, there exists types of graphs in which the roles are reversed and the edges are the objects, and the nodes are the relationships. An example of such a graph is the stream network shown below.
In the above figure, the objects (edges) are the stream segments and the relationship (nodes) between them is endpoint sharing. However, if desirable one could model the second case similar to the first. The resulting graph is shown below.
The Graph object is intended to serve as a container for a collection of nodes and edges. It does dont define or manage the relationship among the components it contains.


Field Summary
Fields Modifier and Type Field Description static int
FAIL_QUERY
Signal to indicate that a graph component does NOT meet the requirements of a query made against the graph.static int
PASS_AND_CONTINUE
Signal to indicate that a graph component meets the requirements of a query against a graph and that the query should continue.static int
PASS_AND_STOP
Signal to indicate that a graph component meets the requirements of a query against a graph and that the query should end.

Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Collection<Edge>
getEdges()
Returns the edges of the graph.Collection<Node>
getNodes()
Returns the nodes of the graph.List<Node>
getNodesOfDegree(int n)
Returns all the nodes in the graph of a specified degree.List<Edge>
getVisitedEdges(boolean visited)
Returns all the edges in the graph that have been marked as visited or nonvisited.List<Node>
getVisitedNodes(boolean visited)
Returns all the nodes in the graph that have been marked as visited or nonvisited.List<? extends Graphable>
queryEdges(GraphVisitor visitor)
Performs a query against the edges of the graph.List<Node>
queryNodes(GraphVisitor visitor)
Performs a query against the nodes of the graph.void
visitEdges(GraphVisitor visitor)
Applies the visitor pattern to the edges of the graph.void
visitNodes(GraphVisitor visitor)
Applies the visitor pattern to the nodes of the graph.



Field Detail

PASS_AND_CONTINUE
static final int PASS_AND_CONTINUE
Signal to indicate that a graph component meets the requirements of a query against a graph and that the query should continue. See Also:
 Constant Field Values

PASS_AND_STOP
static final int PASS_AND_STOP
Signal to indicate that a graph component meets the requirements of a query against a graph and that the query should end. See Also:
 Constant Field Values

FAIL_QUERY
static final int FAIL_QUERY
Signal to indicate that a graph component does NOT meet the requirements of a query made against the graph. See Also:
 Constant Field Values


Method Detail

getNodes
Collection<Node> getNodes()
Returns the nodes of the graph. Returns:
 A collection of Node objects.
 See Also:
Node

getEdges
Collection<Edge> getEdges()
Returns the edges of the graph. Returns:
 A collection of Edge objects.
 See Also:
Edge

queryNodes
List<Node> queryNodes(GraphVisitor visitor)
Performs a query against the nodes of the graph. Each Node object contained in the graph is passed to a GraphVisitor to determine if it meets the query criteria. Parameters:
visitor
 Determines if node meets query criteria. Returns MEET_AND_CONTINUE to signal that the node meets the query criteria and the query should continue.
Returns MEET_AND_STOP to signal that the node meest the query criteria and the query should stop.
FAIL_QUERY to signal that the node does NOT meet the query criteria. Returns:
 A collection of nodes that meet the query criteria.
 See Also:
Node
,GraphVisitor

queryEdges
List<? extends Graphable> queryEdges(GraphVisitor visitor)
Performs a query against the edges of the graph. Each Edge object contained in the graph is passed to a GraphVisitor to determine if it meets the query criteria. Parameters:
visitor
 Determines if the meets the query criteria.
Returns MEET_AND_CONTINUE to signal that the edge meets the query criteria and the query should continue.
Returns MEET_AND_STOP to signal that the edge meest the query criteria and the query should stop.
FAIL_QUERY to signal that the edge does NOT meet the query criteria. Returns:
 A collection of edges that meet the query criteria.
 See Also:
Edge
,GraphVisitor

visitNodes
void visitNodes(GraphVisitor visitor)
Applies the visitor pattern to the nodes of the graph.

visitEdges
void visitEdges(GraphVisitor visitor)
Applies the visitor pattern to the edges of the graph.

getNodesOfDegree
List<Node> getNodesOfDegree(int n)
Returns all the nodes in the graph of a specified degree. The degree of a node is the number of edges that are adjacent to the node. Parameters:
n
 The desired degree of nodes to be returned. Returns:
 A collection of nodes of degree n.
 See Also:
Node.getDegree()

getVisitedNodes
List<Node> getVisitedNodes(boolean visited)
Returns all the nodes in the graph that have been marked as visited or nonvisited. Parameters:
visited
 True if node is visited, false if node is unvisited. Returns:
 List of nodes marked as visited / nonvisited.
 See Also:
Graphable.isVisited()

getVisitedEdges
List<Edge> getVisitedEdges(boolean visited)
Returns all the edges in the graph that have been marked as visited or nonvisited. Parameters:
visited
 True if edge is visited, false if edge is unvisited. Returns:
 List of edges marked as visited / nonvisited.
 See Also:
Graphable.isVisited()

