|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttreebolic.model.graph.Graph
public class Graph
Graph
Field Summary | |
---|---|
(package private) static boolean |
dfs
|
protected java.util.Set<GraphEdge> |
theEdges
The set of edges |
protected java.util.Set<GraphNode> |
theNodes
The set of nodes. |
Constructor Summary | |
---|---|
protected |
Graph()
Constructor |
Method Summary | |
---|---|
java.util.Collection<GraphEdge> |
getEdges()
Returns a unmodifiable Collection of all the edges of this graph. |
java.util.Collection<GraphEdge> |
getEdges(GraphNode thisNode)
Gets an unmodifiable collection of all edges adjacent to thisNode . |
java.util.Collection<GraphNode> |
getNodes()
Returns a unmodifiable Collection of all nodes of this graph. |
java.util.Map<GraphNode,java.util.Collection<GraphEdge>> |
getNodeToEdgesMap()
Returns a unmodifiable Map of all edges of this graph. |
GraphNode |
getNodeWithMinimumIncomingDegree()
Determines a node with the minimal incoming degree. |
java.util.Collection<GraphEdge> |
getNonTreeEdges(GraphNode thisNode)
Gets an unmodifiable collection of all edges adjacent to thisNode that has been marked as tree. |
java.util.Collection<GraphEdge> |
getTreeEdges(GraphNode thisNode)
Gets an unmodifiable collection of all edges adjacent to thisNode that has been marked as tree. |
Tree |
makeSpanningTree()
Returns a spanning tree of the graph. |
private void |
processSpanningTreeBFS(Graph thisSpanningTree,
GraphNode thisRoot)
Populate breadth-first search |
private void |
processSpanningTreeDFS(Graph thisSpanningTree,
GraphNode thisRoot)
Populate depth-first search |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
static final boolean dfs
protected java.util.Set<GraphNode> theNodes
protected java.util.Set<GraphEdge> theEdges
Constructor Detail |
---|
protected Graph()
Method Detail |
---|
public java.util.Collection<GraphNode> getNodes()
Collection
of all nodes of this graph. The result is unmodifiable because any deletions in the collection would
leave the graph in an undefined state. To delete or add a node, the methods in this class must be used.
public java.util.Collection<GraphEdge> getEdges()
Collection
of all the edges of this graph. The result is unmodifiable because any deletions in the collection would
leave the graph in an undefined state. To delete or add an edge, the methods in this class must be used.
public java.util.Collection<GraphEdge> getTreeEdges(GraphNode thisNode)
thisNode
that has been marked as tree. This method ignores the direction of the
edges.
thisNode
- node.
public java.util.Collection<GraphEdge> getNonTreeEdges(GraphNode thisNode)
thisNode
that has been marked as tree. This method ignores the direction of the
edges.
thisNode
- node.
public java.util.Collection<GraphEdge> getEdges(GraphNode thisNode)
thisNode
. This method ignores the direction of the theEdges.
thisNode
- node.
public java.util.Map<GraphNode,java.util.Collection<GraphEdge>> getNodeToEdgesMap()
Map
of all edges of this graph. The result is unmodifiable because any deletions in the collection would leave
the graph in an undefined state. To delete or add an edge, the methods in this class must be used.
public Tree makeSpanningTree()
Tree
, the nodes of the original graph and the spanning tree
are shared and the edges are either shared or the spanning tree uses the reverse edges. The root of the spanning tree is the node that is returned by
getNodeWithMinimumIncomingDegree()
, i.e. a node with minimal incoming degree. The spanning tree is directed, i.e. the direction of all the
edges is as it is expected for trees.
private void processSpanningTreeDFS(Graph thisSpanningTree, GraphNode thisRoot)
thisSpanningTree
- spanning tree (stub)thisRoot
- starting nodeprivate void processSpanningTreeBFS(Graph thisSpanningTree, GraphNode thisRoot)
thisSpanningTree
- spanning tree (stub)thisRoot
- starting nodepublic GraphNode getNodeWithMinimumIncomingDegree()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |