javaslam.tjt.graph
Class Node

java.lang.Object
  |
  +--javaslam.tjt.graph.Node
Direct Known Subclasses:
JunctionTree.Cluster

public class Node
extends Object

A node in a graph. The equals and hashCode methods are implemented exactly as in the Object class. Thus, it is not possible to have two representations of the same node.


Field Summary
protected  Map edges
          A mapping from neighbor Nodes to the Edges to them.
 
Constructor Summary
Node()
          Default constructor.
 
Method Summary
 void addEdge(Edge e)
          Adds an edge from this node to another node.
 Collection edges()
          Returns (an unmodifiable view of) the set of Edges incident from this node.
 boolean equals(Object o)
          Finalizes the definition of equals so that two nodes are equal iff they are the same object.
 Edge getEdge(Node n)
          Gets the edge from this node to the supplied node; if no such edge exists, null is returned.
 List getShortestPath(NodeFilter f)
          Computes the shortest path from this node to another node satisfying a particular property.
 int hashCode()
          Finalizes the definition of hashCode to be the same as that of hashCode.
 void removeEdge(Edge e)
          Removes the supplied edge from this node to the supplied node (if such an edge exists).
 void swingEdge(Edge e, Node n)
          Changes an edge emanating from this node so that it emanates from the supplied node.
 void swingEdgesTo(Node n)
          Changes the origin of all (directed and undirected) edges emanating from this node to the supplied node.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

edges

protected Map edges
A mapping from neighbor Nodes to the Edges to them.

Constructor Detail

Node

public Node()
Default constructor.

Method Detail

addEdge

public void addEdge(Edge e)
Adds an edge from this node to another node. If the edge's from field is not this, then it is set to this.

Parameters:
e - the edge to add to this node's list of outward edges
Throws:
IllegalArgumentException - if the edge's to field is equal to this.

swingEdge

public void swingEdge(Edge e,
                      Node n)
Changes an edge emanating from this node so that it emanates from the supplied node. If the terminus of the edge is the same as the supplied node, then the edge is simply deleted. This method has no effect if the supplied edge does not emanate from this node.

Parameters:
e - the edge to swing
n - the new terminus of e

swingEdgesTo

public void swingEdgesTo(Node n)
Changes the origin of all (directed and undirected) edges emanating from this node to the supplied node. Edges between this node and the supplied node are dropped.

Parameters:
n - the new origin of all edges emanating from this node

getEdge

public Edge getEdge(Node n)
Gets the edge from this node to the supplied node; if no such edge exists, null is returned.

Parameters:
n - the neighbor of this node
Returns:
the edge from this node to n, or null if n is not a neighbor of this node

removeEdge

public void removeEdge(Edge e)
Removes the supplied edge from this node to the supplied node (if such an edge exists).

Parameters:
e - an edge emanating from this node

edges

public Collection edges()
Returns (an unmodifiable view of) the set of Edges incident from this node.

Returns:
(an unmodifiable view of) the set of Edges emanating from this node

getShortestPath

public List getShortestPath(NodeFilter f)
Computes the shortest path from this node to another node satisfying a particular property. The path is returned as a List of Edge objects. If there are no nodes reachable from this node that satisfy the filter, then null is returned.

Parameters:
f - a filter identifying nodes that have a particular property
Returns:
a path to the node closest to this one (in path length) that satisfies the filter (or null if no node satisfying the property is reachable from this node).

equals

public final boolean equals(Object o)
Finalizes the definition of equals so that two nodes are equal iff they are the same object.

Overrides:
equals in class Object
Parameters:
o - another object
Returns:
true iff o == this

hashCode

public final int hashCode()
Finalizes the definition of hashCode to be the same as that of hashCode.

Overrides:
hashCode in class Object