Package org.geotools.graph.structure.opt
Class OptNode
- Object
-
- OptGraphable
-
- OptNode
-
- All Implemented Interfaces:
Serializable
,Graphable
,Node
- Direct Known Subclasses:
OptXYNode
public class OptNode extends OptGraphable implements Node
Optimized implementation of Node. The following optimizations reduce space and improve performance.
- Edge adjacency list stored as array of predetermined size.
- Removing support for removing edges from the nodes ajdacency list.
- The related component iterator iterates over the underlying edge array of the node instread of a newly created collection.
- Author:
- Justin Deoliveira, Refractions Research Inc, jdeolive@refractions.net
- See Also:
Node
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
OptNode.RelatedIterator
An iterator used to iterate over related nodes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Edge e)
Adds an edge to the 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.Edge[]
getEdgeArray()
Returns the edge adjacency list of the node as an array.List<Edge>
getEdges()
Returns the edge adjacency list of the node.List<Edge>
getEdges(Node other)
Returns a collection of edges in the adjacency list of the node that are adjacent to another specified node.Iterator<Node>
getRelated()
This iterator iterates over the underlying edge array of the node.void
remove(Edge e)
Not supported.void
setDegree(int degree)
Sets the degree of the node.-
Methods inherited from class OptGraphable
getCount, getID, getObject, isVisited, setCount, setID, setObject, setVisited
-
-
-
-
Method Detail
-
add
public void add(Edge e)
Description copied from interface:Node
Adds an edge to the adjacency list of the node.- Specified by:
add
in interfaceNode
- Parameters:
e
- Adjacent edge to add.- See Also:
Node.add(Edge)
-
remove
public void remove(Edge e)
Not supported.- Specified by:
remove
in interfaceNode
- Parameters:
e
- Adjacent edge to remove.- 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 interfaceNode
- 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)
-
getEdges
public List<Edge> 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 interfaceNode
- 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)
-
getEdgeArray
public Edge[] getEdgeArray()
Returns the edge adjacency list of the node as an array.- Returns:
- An array containing edges adjacent to the node.
-
getEdges
public List<Edge> getEdges()
Description copied from interface:Node
Returns the edge adjacency list of the node.- Specified by:
getEdges
in interfaceNode
- Returns:
- A list containing all edges that are adjacent to the node.
- See Also:
Node.getEdges()
-
setDegree
public void setDegree(int degree)
Sets the degree of the node. This method build the edge adjacency array for the node.- Parameters:
degree
- The degree of the node / size of edge adjacency array.
-
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 interfaceNode
- Returns:
- int Degree of node.
- See Also:
Node.getDegree()
-
getRelated
public Iterator<Node> getRelated()
This iterator iterates over the underlying edge array of the node.- Specified by:
getRelated
in interfaceGraphable
- Returns:
- Iterator An iterator over other components of the graph that are related to the component.
- See Also:
Graphable.getRelated()
-
-