Class BasicNode
- Object
-
- BasicGraphable
-
- BasicNode
-
- All Implemented Interfaces:
Serializable,Graphable,Node
- Direct Known Subclasses:
BasicXYNode
public class BasicNode extends BasicGraphable implements Node
Basic implementation of Node.- Author:
- Justin Deoliveira, Refractions Research Inc, jdeolive@refractions.net
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BasicNode()Constructs a BasicNode.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Edge e)Adds an edge to the adjacency list of the node which is an underlying List implementation.intgetDegree()Returns the degree of the node.EdgegetEdge(Node other)Returns an edge in the adjacency list of the node that is adjacent to another specified node.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()Returns all nodes that are incident with adjacent edges minus itself.voidremove(Edge e)Removes an edge from the adjacency list of the node.-
Methods inherited from class BasicGraphable
getCount, getID, getObject, isVisited, setCount, setID, setObject, setVisited, toString
-
-
-
-
Method Detail
-
add
public void add(Edge e)
Adds an edge to the adjacency list of the node which is an underlying List implementation. No checking is done on the edge (duplication, looping...), it is simply added to the list.- Specified by:
addin interfaceNode- Parameters:
e- Adjacent edge to add.- See Also:
Node.add(Edge)
-
remove
public void remove(Edge e)
Description copied from interface:NodeRemoves an edge from the adjacency list of the node.- Specified by:
removein interfaceNode- Parameters:
e- Adjacent edge to remove.- See Also:
Node.remove(Edge)
-
getDegree
public int getDegree()
Description copied from interface:NodeReturns 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:
getDegreein interfaceNode- Returns:
- int Degree of node.
- See Also:
Node.getDegree()
-
getEdge
public Edge getEdge(Node other)
Description copied from interface:NodeReturns 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:
getEdgein 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:NodeReturns a collection of edges in the adjacency list of the node that are adjacent to another specified node.- Specified by:
getEdgesin 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)
-
getEdges
public List<Edge> getEdges()
Description copied from interface:NodeReturns the edge adjacency list of the node.- Specified by:
getEdgesin interfaceNode- Returns:
- A list containing all edges that are adjacent to the node.
- See Also:
Node.getEdges()
-
getRelated
public Iterator<Node> getRelated()
Returns all nodes that are incident with adjacent edges minus itself. This iterator is generated by calculating an underlying collection upon each method call.- Specified by:
getRelatedin interfaceGraphable- Returns:
- Iterator An iterator over other components of the graph that are related to the component.
- See Also:
Graphable.getRelated()
-
-