|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.util.graph.Graph<T>
T - public class Graph<T>
A directed graph data structure.
| Field Summary | |
|---|---|
static int |
VISIT_COLOR_BLACK
Color used to mark nodes after descendants are completely visited |
static int |
VISIT_COLOR_GREY
Color used to mark nodes as they are first visited in DFS order |
static int |
VISIT_COLOR_WHITE
Color used to mark unvisited nodes |
| Constructor Summary | |
|---|---|
Graph()
Construct a new graph without any vertices or edges |
|
| Method Summary | ||
|---|---|---|
boolean |
addEdge(Vertex<T> from,
Vertex<T> to,
int cost)
Insert a directed, weighted Edge |
|
boolean |
addVertex(Vertex<T> v)
Add a vertex to the graph |
|
void |
breadthFirstSearch(Vertex<T> v,
Visitor<T> visitor)
Perform a breadth first search of this graph, starting at v. |
|
|
breadthFirstSearch(Vertex<T> v,
VisitorEX<T,E> visitor)
Perform a breadth first search of this graph, starting at v. |
|
void |
clearEdges()
Clear the mark state of all edges in the graph by calling clearMark() on all edges. |
|
void |
clearMark()
Clear the mark state of all verticies in the graph by calling clearMark() on all verticies. |
|
void |
depthFirstSearch(Vertex<T> v,
Visitor<T> visitor)
Perform a depth first serach using recursion. |
|
|
depthFirstSearch(Vertex<T> v,
VisitorEX<T,E> visitor)
Perform a depth first serach using recursion. |
|
void |
dfsSpanningTree(Vertex<T> v,
DFSVisitor<T> visitor)
Find the spanning tree using a DFS starting from v. |
|
Edge<T>[] |
findCycles()
Search the graph for cycles. |
|
Vertex<T> |
findVertexByData(T data,
Comparator<T> compare)
Search the verticies for one with data. |
|
Vertex<T> |
findVertexByName(String name)
Search the verticies for one with name. |
|
List<Edge<T>> |
getEdges()
Get the graph edges |
|
Vertex<T> |
getRootVertex()
Get the root vertex |
|
Vertex<T> |
getVertex(int n)
Get the given Vertex. |
|
List<Vertex<T>> |
getVerticies()
Get the graph verticies |
|
boolean |
insertBiEdge(Vertex<T> from,
Vertex<T> to,
int cost)
Insert a bidirectional Edge |
|
boolean |
isEmpty()
Are there any verticies in the graph |
|
boolean |
removeEdge(Vertex<T> from,
Vertex<T> to)
Remove an Edge |
|
boolean |
removeVertex(Vertex<T> v)
Remove a vertex from the graph |
|
void |
setRootVertex(Vertex<T> root)
Set a root vertex. |
|
int |
size()
Get the vertex count. |
|
String |
toString()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int VISIT_COLOR_WHITE
public static final int VISIT_COLOR_GREY
public static final int VISIT_COLOR_BLACK
| Constructor Detail |
|---|
public Graph()
| Method Detail |
|---|
public boolean isEmpty()
public boolean addVertex(Vertex<T> v)
v - the Vertex to add
public int size()
public Vertex<T> getRootVertex()
public void setRootVertex(Vertex<T> root)
root - - the vertex to set as the root and optionally add if it
does not exist in the graph.public Vertex<T> getVertex(int n)
n - the index [0, size()-1] of the Vertex to access
public List<Vertex<T>> getVerticies()
public boolean addEdge(Vertex<T> from,
Vertex<T> to,
int cost)
throws IllegalArgumentException
from - - the Edgeto - - the Edgecost - - the EdgeIllegalArgumentException - if from/to are not verticies in
the graph
public boolean insertBiEdge(Vertex<T> from,
Vertex<T> to,
int cost)
throws IllegalArgumentException
from - - the Edgeto - - the Edgecost - - the EdgeIllegalArgumentException - if from/to are not verticies in
the graphpublic List<Edge<T>> getEdges()
public boolean removeVertex(Vertex<T> v)
v - the Vertex to remove
public boolean removeEdge(Vertex<T> from,
Vertex<T> to)
from - - the Edgeto - - the Edgepublic void clearMark()
Vertex.clearMark()public void clearEdges()
public void depthFirstSearch(Vertex<T> v,
Visitor<T> visitor)
v - - the Vertex to start the search fromvisitor - - the vistor to inform prior toVisitor.visit(Graph, Vertex)
public <E extends Exception> void depthFirstSearch(Vertex<T> v,
VisitorEX<T,E> visitor)
throws E extends Exception
E - v - - the Vertex to start the search fromvisitor - - the vistor to inform prior to
E - if visitor.visit throws an exception
E extends ExceptionVisitor.visit(Graph, Vertex)
public void breadthFirstSearch(Vertex<T> v,
Visitor<T> visitor)
v - - the search starting pointvisitor - - the vistor whose vist method is called prior
to visting a vertex.
public <E extends Exception> void breadthFirstSearch(Vertex<T> v,
VisitorEX<T,E> visitor)
throws E extends Exception
E - v - - the search starting pointvisitor - - the vistor whose vist method is called prior
to visting a vertex.
E - if vistor.visit throws an exception
E extends Exception
public void dfsSpanningTree(Vertex<T> v,
DFSVisitor<T> visitor)
v - - the vertex to start the search fromvisitor - - visitor invoked after each vertex
is visited and an edge is added to the tree.public Vertex<T> findVertexByName(String name)
name - - the vertex name
public Vertex<T> findVertexByData(T data,
Comparator<T> compare)
data - - the vertex data to matchcompare - - the comparator to perform the match
public Edge<T>[] findCycles()
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||