org.geotools.graph.structure.opt
Class OptDirectedNode

java.lang.Object
  extended byorg.geotools.graph.structure.opt.OptGraphable
      extended byorg.geotools.graph.structure.opt.OptDirectedNode
All Implemented Interfaces:
DirectedGraphable, DirectedNode, Graphable, Node, java.io.Serializable
Direct Known Subclasses:
OptDirectedXYNode

public class OptDirectedNode
extends OptGraphable
implements DirectedNode

Optimized implementation of DirectedNode. The following optimizations reduce space and increase performance.

Using an optimized directed node requires that the size of the in and out edge adjacency lists be known before its creation.

Author:
Justin Deoliveira, Refractions Research Inc, jdeolive@refractions.net
See Also:
DirectedNode, Serialized Form

Nested Class Summary
 class OptDirectedNode.RelatedIterator
          Iterator used to iterate over related nodes.
 
Constructor Summary
OptDirectedNode()
          Constructs a new OptDirectedNode.
OptDirectedNode(int indegree, int outdegree)
          Constructs a new OptDirectedNode.
 
Method Summary
 void add(Edge e)
          Not supported.
 void addIn(DirectedEdge e)
          Adds an edge to the in adjacency list of the node.
 void addOut(DirectedEdge e)
          Adds an edge to the out adjacency list of the node.
 int getDegree()
          Returns the degree of the node.
 Edge getEdge(Node other)
          Returns an edge in the adjacency list of the node that is adjacent to another specified node.
 java.util.List getEdges()
          Returns the edge adjacency list of the node.
 java.util.List getEdges(Node other)
          Returns a collection of edges in the adjacency list of the node that are adjacent to another specified node.
 int getInDegree()
          Returns the in degree of the node.
 Edge getInEdge(DirectedNode other)
          Returns an edge that terminates at the node and originates from a specified node.
 DirectedEdge[] getInEdgeArray()
          Returns the in adjacency edge array of the node.
 java.util.List getInEdges()
          Returns the in adjacency list of the node.
 java.util.List getInEdges(DirectedNode other)
          Returns all edges that terminate at the node and originate from a specified node.
 java.util.Iterator getInRelated()
          This iterator iterates over the underlying in edge array of the node.
 int getOutDegree()
          Returns the out degree of the node.
 Edge getOutEdge(DirectedNode other)
          Returns an edge that originates at the node and terminates at a specified node.
 DirectedEdge[] getOutEdgeArray()
          Returns the out adjacency edge array of the node.
 java.util.List getOutEdges()
          Returns the out adjacency list of the node.
 java.util.List getOutEdges(DirectedNode other)
          Returns all edges that originate at the node and terminate from at specified node.
 java.util.Iterator getOutRelated()
          This iterator iterates over the underlying out edge array of the node.
 java.util.Iterator getRelated()
          This iterator iterates over the underlying edge arrays of the node.
 void remove(Edge e)
          Unsupported Operation.
 void removeIn(DirectedEdge e)
          Unsupported Operation.
 void removeOut(DirectedEdge e)
          Unsupported Operation.
 void setInDegree(int indegree)
          Sets the in degree of the node.
 void setOutDegree(int outdegree)
          Sets the out degree of the node.
 
Methods inherited from class org.geotools.graph.structure.opt.OptGraphable
getCount, getID, getObject, isVisited, setCount, setID, setObject, setVisited
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.geotools.graph.structure.Graphable
getCount, getID, getObject, isVisited, setCount, setID, setObject, setVisited
 

Constructor Detail

OptDirectedNode

public OptDirectedNode()
Constructs a new OptDirectedNode. This constructor does not create the edge adjacency arrays for the node.


OptDirectedNode

public OptDirectedNode(int indegree,
                       int outdegree)
Constructs a new OptDirectedNode.

Parameters:
indegree - Number of in adjacenct edges to the node.
outdegree - Number of out adjacent edges to the node.
Method Detail

add

public void add(Edge e)
Not supported.

Specified by:
add in interface Node
Parameters:
e - Adjacent edge to add.
Throws:
java.lang.UnsupportedOperationException

addIn

public void addIn(DirectedEdge e)
Description copied from interface: DirectedNode
Adds an edge to the in adjacency list of the node.

Specified by:
addIn in interface DirectedNode
Parameters:
e - A directed edge that terminates at the node.
See Also:
DirectedNode.addIn(DirectedEdge)

addOut

public void addOut(DirectedEdge e)
Description copied from interface: DirectedNode
Adds an edge to the out adjacency list of the node.

Specified by:
addOut in interface DirectedNode
Parameters:
e - A directed edge that originates from the node.
See Also:
DirectedNode.addOut(DirectedEdge)

remove

public void remove(Edge e)
Unsupported Operation.

Specified by:
remove in interface Node
Parameters:
e - Adjacent edge to remove.
Throws:
java.lang.UnsupportedOperationException

removeIn

public void removeIn(DirectedEdge e)
Unsupported Operation.

Specified by:
removeIn in interface DirectedNode
Parameters:
e - A directed edge that terminates at the node.
Throws:
java.lang.UnsupportedOperationException
See Also:
Node.remove(Edge)

removeOut

public void removeOut(DirectedEdge e)
Unsupported Operation.

Specified by:
removeOut in interface DirectedNode
Parameters:
e - A directed edge that originates from the node.
Throws:
java.lang.UnsupportedOperationException
See Also:
Node.remove(Edge)

getEdge

public Edge getEdge(Node other)
Description copied from interface: Node
Returns an edge in the adjacency list of the node that is adjacent to another specified node.

Note: It is possible for two nodes to share multiple edges between them. In this case, getEdges(Node other) can be used to obtain a complete list.

Specified by:
getEdge in interface Node
Parameters:
other - The other node that the desired edge to return is adjacent to.
Returns:
The first edge that is found to be adjacent to the specified node.
See Also:
Node.getEdge(Node)

getInEdge

public Edge getInEdge(DirectedNode other)
Description copied from interface: DirectedNode
Returns an edge that terminates at the node and originates from a specified node.

Note: It is possible for two nodes to share multiple edges between them. In this case, getInEdges(Node other) can be used to obtain a complete list.

Specified by:
getInEdge in interface DirectedNode
Parameters:
other - The originating node.
Returns:
The first edge found to terminate at the node and originate from the specefied node.
See Also:
DirectedNode.getInEdge(DirectedNode)

getOutEdge

public Edge getOutEdge(DirectedNode other)
Description copied from interface: DirectedNode
Returns an edge that originates at the node and terminates at a specified node.

Note: It is possible for two nodes to share multiple edges between them. In this case, getOutEdges(Node other) can be used to obtain a complete list.

Specified by:
getOutEdge in interface DirectedNode
Parameters:
other - The terminating node.
Returns:
The first edge found to originate at the node and terminate at the specefied node.
See Also:
DirectedNode.getOutEdge(DirectedNode)

getEdges

public java.util.List getEdges(Node other)
Description copied from interface: Node
Returns a collection of edges in the adjacency list of the node that are adjacent to another specified node.

Specified by:
getEdges in interface Node
Parameters:
other - The other node that the desired edges to return are adjacent to.
Returns:
List of all edges that are found to be adjacent to the specified node.
See Also:
Node.getEdges(Node)

getInEdges

public java.util.List getInEdges(DirectedNode other)
Description copied from interface: DirectedNode
Returns all edges that terminate at the node and originate from a specified node.

Specified by:
getInEdges in interface DirectedNode
Parameters:
other - The originating node.
Returns:
All edges found to terminate at the node and originate from the specified node.
See Also:
DirectedNode.getInEdges(DirectedNode)

getOutEdges

public java.util.List getOutEdges(DirectedNode other)
Description copied from interface: DirectedNode
Returns all edges that originate at the node and terminate from at specified node.

Specified by:
getOutEdges in interface DirectedNode
Parameters:
other - The temimnating node.
Returns:
All edges found to originate at the node and terminate at the specified node.
See Also:
DirectedNode.getOutEdges(DirectedNode)

getEdges

public java.util.List getEdges()
Description copied from interface: Node
Returns the edge adjacency list of the node.

Specified by:
getEdges in interface Node
Returns:
A list containing all edges that are adjacent to the node.
See Also:
Node.getEdges()

getInEdgeArray

public DirectedEdge[] getInEdgeArray()
Returns the in adjacency edge array of the node.

Returns:
An array of in edges for the node.

getInEdges

public java.util.List getInEdges()
Description copied from interface: DirectedNode
Returns the in adjacency list of the node.

Specified by:
getInEdges in interface DirectedNode
Returns:
A list of edges that terminate at the node.
See Also:
DirectedNode.getInEdges()

getOutEdgeArray

public DirectedEdge[] getOutEdgeArray()
Returns the out adjacency edge array of the node.

Returns:
An array of out edges for the node.

getOutEdges

public java.util.List getOutEdges()
Description copied from interface: DirectedNode
Returns the out adjacency list of the node.

Specified by:
getOutEdges in interface DirectedNode
Returns:
A list of edges originating at the node.
See Also:
DirectedNode.getOutEdges()

getDegree

public int getDegree()
Description copied from interface: Node
Returns the degree of the node. The degree of a node is defined as the number of edges that are adjacent to the node.

Specified by:
getDegree in interface Node
Returns:
int Degree of node.
See Also:
Node.getDegree()

setInDegree

public void setInDegree(int indegree)
Sets the in degree of the node. This method builds the in edge adjacency list of the node.

Parameters:
indegree - The in degree / size of in edge array of the node.

getInDegree

public int getInDegree()
Description copied from interface: DirectedNode
Returns the in degree of the node.

Specified by:
getInDegree in interface DirectedNode
Returns:
The number of edges that terminate at the node.
See Also:
DirectedNode.getInDegree()

setOutDegree

public void setOutDegree(int outdegree)
Sets the out degree of the node. This method builds the out edge adjacency list of the node.


getOutDegree

public int getOutDegree()
Description copied from interface: DirectedNode
Returns the out degree of the node.

Specified by:
getOutDegree in interface DirectedNode
Returns:
The number of edges that originate at the node.
See Also:
DirectedNode.getOutDegree()

getRelated

public java.util.Iterator getRelated()
This iterator iterates over the underlying edge arrays of the node.

Specified by:
getRelated in interface Graphable
Returns:
Iterator An iterator over other components of the graph that are related to the component.
See Also:
Graphable.getRelated()

getInRelated

public java.util.Iterator getInRelated()
This iterator iterates over the underlying in edge array of the node.

Specified by:
getInRelated in interface DirectedGraphable
Returns:
An iterator over the other directed components related through an in relationship.
See Also:
DirectedGraphable.getInRelated()

getOutRelated

public java.util.Iterator getOutRelated()
This iterator iterates over the underlying out edge array of the node.

Specified by:
getOutRelated in interface DirectedGraphable
Returns:
An iterator over the other directed components related through an out relationship.
See Also:
Graphable.getRelated()


Copyright © GeoTools. All Rights Reserved.