|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object spiglet.translate.graph.Node
public class Node
This class represents a node that belongs to a Graph
.
Each node stores a reference to the graph in which it is defined, as well as
the list of successor and predecessor nodes (representing directed edges).
Each graph only stores the minimal information about its node. To store
extra information about what each node represents, external device is
employed (hash mapping, for instance).
Field Summary | |
---|---|
protected Graph |
graph
A reference to the graph this node belongs to. |
protected java.util.Set<Node> |
predecessors
The set of all nodes that edges pointing to this node comes from. |
protected java.util.Set<Node> |
successors
The set of nodes that edges coming out of this node points to. |
Constructor Summary | |
---|---|
protected |
Node(Graph g)
Creates a new node, with the given graph in which it is to be defined. |
Method Summary | |
---|---|
boolean |
adjacent(Node n)
Returns true if this node and the given node are adjacent to
each other. |
int |
degree()
Returns the number of of successors plus predecessors this node has |
boolean |
from(Node n)
Returns true if there is a directed edge from the given node
to this node. |
java.util.Set<Node> |
getAdjacent()
Returns the set of all nodes adjacent to this node (direction blind). |
java.util.Set<Node> |
getPredecessors()
Returns the set (unmodifiable) of all predecessor nodes (nodes that edges pointing to this node comes from) to this node. |
java.util.Set<Node> |
getSuccessors()
Returns the set (unmodifiable) of all successor nodes (nodes that edges coming out of this node points to) to this node. |
int |
inDegree()
Returns the number of predecessors this node has |
int |
outDegree()
Returns the number of successors this node has |
protected static void |
resetCounter()
Resets the static counter that numbers newly created nodes. |
boolean |
to(Node n)
Returns true if there is a directed edge from this node
to the given node. |
java.lang.String |
toString()
String representation of this node is its unique key number. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Graph graph
protected java.util.Set<Node> successors
protected java.util.Set<Node> predecessors
Constructor Detail |
---|
protected Node(Graph g)
g
- the graph that this node would belong toMethod Detail |
---|
public java.util.Set<Node> getSuccessors()
public java.util.Set<Node> getPredecessors()
public java.util.Set<Node> getAdjacent()
public int inDegree()
public int outDegree()
public int degree()
public boolean to(Node n)
true
if there is a directed edge from this node
to the given node.
n
- the destination node
true
if there exists a directed edge between this node
and the given nodepublic boolean from(Node n)
true
if there is a directed edge from the given node
to this node.
n
- the source node
true
if there exists a directed edge between the given
node and this node.public boolean adjacent(Node n)
true
if this node and the given node are adjacent to
each other.
n
- the potential neighbor node
true
if the given node and this node are neighborspublic java.lang.String toString()
toString
in class java.lang.Object
protected static void resetCounter()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |