|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Graph<V,E>
public class Graph<V,E>
Implements a graph.
Nested Class Summary | |
---|---|
class |
Graph.Edge
Implements an edge in a graph. |
class |
Graph.Node
Implements a node in a graph. |
Field Summary | |
---|---|
protected java.util.LinkedList<Graph.Edge> |
edges
The list of edges |
protected java.util.LinkedList<Graph.Node> |
nodes
The list of vertices |
Constructor Summary | |
---|---|
Graph()
Constructor initializes with empty node and edge lists |
Method Summary | |
---|---|
Graph.Edge |
addEdge(E data,
Graph.Node head,
Graph.Node tail)
Adds an edge |
Graph.Node |
addNode(V data)
Adds a node |
java.util.HashSet<Graph.Edge> |
BFT(Graph.Node start)
Breadth-first traversal of graph |
void |
check()
Checks the consistency of the graph |
java.util.HashSet<Graph.Edge> |
DFT(Graph.Node start)
Depth-first traversal of graph -- public interface |
double[] |
distances(Graph.Node start)
Dijkstra's shortest-path algorithm to compute distances to nodes |
java.util.HashSet<Graph.Node> |
endpoints(java.util.HashSet<Graph.Edge> edges)
Returns nodes that are endpoints of a list of edges |
Graph.Edge |
getEdge(int i)
Accessor for edges |
Graph.Edge |
getEdgeRef(Graph.Node head,
Graph.Node tail)
Accessor for specific edge |
Graph.Node |
getNode(int i)
Accessor for nodes |
int |
numEdges()
Accessor for number of edges |
int |
numNodes()
Accessor for number of nodes |
java.util.HashSet<Graph.Node> |
otherNodes(java.util.HashSet<Graph.Node> group)
Returns nodes not on a given list |
void |
print()
Prints a representation of the graph |
void |
removeEdge(Graph.Edge edge)
Removes an edge |
void |
removeEdge(Graph.Node head,
Graph.Node tail)
Removes an edge |
void |
removeNode(Graph.Node node)
Removes a node |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.LinkedList<Graph.Node> nodes
protected java.util.LinkedList<Graph.Edge> edges
Constructor Detail |
---|
public Graph()
Method Detail |
---|
public Graph.Node getNode(int i)
public Graph.Edge getEdge(int i)
public Graph.Edge getEdgeRef(Graph.Node head, Graph.Node tail)
public int numNodes()
public int numEdges()
public Graph.Node addNode(V data)
public Graph.Edge addEdge(E data, Graph.Node head, Graph.Node tail)
public void removeNode(Graph.Node node)
public void removeEdge(Graph.Edge edge)
public void removeEdge(Graph.Node head, Graph.Node tail)
public java.util.HashSet<Graph.Node> otherNodes(java.util.HashSet<Graph.Node> group)
public java.util.HashSet<Graph.Node> endpoints(java.util.HashSet<Graph.Edge> edges)
public java.util.HashSet<Graph.Edge> BFT(Graph.Node start)
public java.util.HashSet<Graph.Edge> DFT(Graph.Node start)
public double[] distances(Graph.Node start)
public void print()
public void check()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |