org.geotools.graph
Class Graph

java.lang.Object
  extended byorg.geotools.graph.Graph

public class Graph
extends java.lang.Object

A Graph is a structure that represents the relationship between a collection of features. These relationships can be represented as either edges or nodes in the graph.


Constructor Summary
Graph(java.util.Collection nodes, java.util.Collection edges)
          Creates a graph that contains a collection of nodes and edges.
 
Method Summary
 org.geotools.feature.FeatureCollection asEdgeFC()
          Convenience method for wrapping the edges of the graph in a FeatureCollection.
 org.geotools.feature.FeatureCollection asNodeFC()
          Convenience method for wrapping the nodes of the graph in a FeatureCollection.
 java.util.Collection getEdges()
          Returns the edges of the graph.
 java.util.Collection getNodes()
          Returns the nodes of the graph.
 java.util.Collection getNodesOfDegree(int n)
          Returns all the nodes in the graph of a specified degree.
 java.util.Collection getVisitedNodes(boolean visited)
          Returns all the nodes in the graph that have been marked as visited or non-visited.
 void init()
          Initialises the graph.
 void initEdges()
          Initializes the edges in the graph by setting all visited flags to false and all counts to zero.
 void initNodes()
          Initializes the nodes in the graph by setting all visited flags to false and all counts to zero.
 java.util.Collection queryEdges(GraphVisitor visitor)
          Performs a query against the edges of the graph.
 java.util.Collection queryNodes(GraphVisitor visitor)
          Performs a query against the nodes of the graph.
 void traverseEdges(GraphTraversal traversal)
          Traverses the edges of the graph.
 void traverseNodes(GraphTraversal traversal)
          Traverses the nodes of a the graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Graph

public Graph(java.util.Collection nodes,
             java.util.Collection edges)
Creates a graph that contains a collection of nodes and edges.

Parameters:
nodes -
edges -
Method Detail

getNodes

public java.util.Collection getNodes()
Returns the nodes of the graph.

Returns:
A collection of Node objects.
See Also:
Node

getEdges

public java.util.Collection getEdges()
Returns the edges of the graph.

Returns:
A collection of Edge objects.
See Also:
Edge

queryNodes

public java.util.Collection 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 - Returns a non zero integer value if the node meets the query criteria.
Returns:
A collection of nodes that meet the query criteria.
See Also:
Node, GraphVisitor

queryEdges

public java.util.Collection 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 - Returns a non zero integer value if the edge meets the query criteria.
Returns:
A collection of edge that meet the query criteria.
See Also:
Edge, GraphVisitor

getNodesOfDegree

public java.util.Collection getNodesOfDegree(int n)
Returns all the nodes in the graph of a specified degree.

Parameters:
n - degree of nodes to be returned.
Returns:
A collection of nodes of degree n.

getVisitedNodes

public java.util.Collection getVisitedNodes(boolean visited)
Returns all the nodes in the graph that have been marked as visited or non-visited.

Parameters:
visited - True if node is visited, false if node is unvisited.
Returns:
Collection of nodes marked as visited / non-visited.

traverseNodes

public void traverseNodes(GraphTraversal traversal)
Traverses the nodes of a the graph.

Parameters:
traversal - Specifies the algorithm in which to traverse the graph.

traverseEdges

public void traverseEdges(GraphTraversal traversal)
Traverses the edges of the graph.

Parameters:
traversal - Specifies the algorithm in which to traverse the graph.

initNodes

public void initNodes()
Initializes the nodes in the graph by setting all visited flags to false and all counts to zero.


initEdges

public void initEdges()
Initializes the edges in the graph by setting all visited flags to false and all counts to zero.


init

public void init()
Initialises the graph.


asNodeFC

public org.geotools.feature.FeatureCollection asNodeFC()
Convenience method for wrapping the nodes of the graph in a FeatureCollection.

Returns:
FeatureCollection
See Also:
FeatureCollection

asEdgeFC

public org.geotools.feature.FeatureCollection asEdgeFC()
Convenience method for wrapping the edges of the graph in a FeatureCollection.

Returns:
FeatureCollection
See Also:
FeatureCollection