|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Description: A graph consists of interconnected nodes. A node must be connected to at least one other node (neighbour). All nodes in a graph are connected so that there are no islands. A single node without any connections is a valid graph. A graph without nodes is a valid graph. Copyright: Copyright (c) 2002 Ortwin Glück
| Method Summary | |
void |
addConnection(Object node1,
Object node2)
Creates a connection between two nodes in a graph. |
void |
addNode(Object node,
Object neighbour)
Adds a node to the graph. |
boolean |
contains(Object node)
Checks if a node is in the graph. |
List |
getNeighbours(Object node)
Gets all nodes connected to the specified node. |
Set |
getNodes()
Gets all the nodes in the graph. |
boolean |
isConnected(Object node1,
Object node2)
Checks if two nodes are connected. |
void |
removeConnection(Object node1,
Object node2)
Removes a connection between two nodes. |
void |
removeNode(Object node)
Removes a node an all its connections from the graph. |
int |
size()
Gets the number of nodes in the graph. |
| Method Detail |
public void addNode(Object node,
Object neighbour)
throws GraphException
node is already a member of the
graph a connection is created and no exception is thrown.node - The node to addneighbour - A neighbour of the new node that is already a member of
the graph. If you add a node to an empty graph this parameter is ignored.public void removeNode(Object node)
public boolean contains(Object node)
public void addConnection(Object node1,
Object node2)
public void removeConnection(Object node1,
Object node2)
throws LastConnectionException
public List getNeighbours(Object node)
public Set getNodes()
public boolean isConnected(Object node1,
Object node2)
public int size()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||