|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.byu.ece.graph.AbstractGraph
edu.byu.ece.graph.BasicGraph
public class BasicGraph
Data structure for representing a simple directed graph.
This class contains the state associated with edges and nodes. The edges are
represented within NodeEdgeMap objects and all connectivity
information is obtained by querying these Map objects.
The actual objects used for edges and nodes can be specified by an application-specific graph data structure.
| Field Summary | |
|---|---|
protected java.util.HashSet |
_nodes
The Set of Node objects contained within the graph. |
protected NodeEdgeMap |
_nodeSinkMap
A Map between graph "node" objects (which are implementation specific) and Collection objects (value). |
protected NodeEdgeMap |
_nodeSourceMap
A Map between graph "node" objects (which are implementation specific) and Collection objects (value). |
| Constructor Summary | |
|---|---|
BasicGraph()
Create an empty graph with no nodes or edges. |
|
BasicGraph(BasicGraph graph)
Create new graph that is a copy of the graph passed in as a parameter. |
|
BasicGraph(java.util.Collection nodes)
Create an empty graph initialized with the nodes passed in as a Collection but with no edges. |
|
BasicGraph(int nodeCount)
Create an empty graph with no nodes or edges. |
|
| Method Summary | |
|---|---|
boolean |
addEdge(Edge edge)
Adds the given Edge from the graph |
void |
addNode(java.lang.Object node)
Add a node object. |
void |
addNodes(java.util.Collection nodes)
Add a collection of node objects. |
java.lang.Object |
clone()
Clone the BasicGraph object. |
boolean |
containsNode(java.lang.Object o)
Determines if the given object is contained as a node within the graph. |
Edge |
getEdge(java.lang.Object source,
java.lang.Object sink)
Returns the first edge found that corresponds to the given source and sink objects. |
java.util.Collection<? extends Edge> |
getEdges()
Return a Collection of all edges in the graph. |
java.util.Collection<? extends Edge> |
getEdges(java.lang.Object source,
java.lang.Object sink)
Returns a collection of edges found that correspond to the given source and sink objects. |
java.util.Collection |
getInputEdges(java.lang.Object node)
Return all links in which the specified node Object is the "sink". |
java.util.Collection |
getNodes()
Return all the node objects in the graph. |
java.util.Collection |
getNodesWithNoInputEdges()
|
java.util.Collection |
getNodesWithNoOutputEdges()
|
java.util.Collection |
getOutputEdges(java.lang.Object node)
Return all links in which the specified node Object is the "source". |
java.util.Collection |
getSinkNodes()
Returns a Collection of nodes which have no predecessors. |
java.util.Collection |
getSourceNodes()
Returns a Collection of nodes which have no predecessors. |
BasicGraph |
getSubGraph(java.util.Collection nodeCollection)
Creates a sub-graph of the given graph from a sub-set of nodes in the graph. |
BasicGraph |
getSubGraph2(java.util.Collection nodes)
|
DirectedGraph |
invert()
|
boolean |
removeEdge(Edge edge)
Removes the given Edge from the graph |
void |
removeEdges(java.util.Collection edges)
|
void |
removeNode(java.lang.Object node)
Removes the given node Object from the graph Also removes ALL Edges in the graph that refer to this node |
void |
removeNode(java.lang.Object node,
boolean removeAllEdges)
Removes the given node Object from the graph |
static java.util.List |
topologicalSort(AbstractEdifGraph graph)
Performs a topological sort on the given acyclic AbstractEdifGraph. |
| Methods inherited from class edu.byu.ece.graph.AbstractGraph |
|---|
_getAncestorsOrDescendents, _getAncestorsOrDescendents, getAncestors, getAncestors, getDescendents, getDescendents, getPredecessors, getSuccessors, toDotty, toString |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected NodeEdgeMap _nodeSourceMap
protected NodeEdgeMap _nodeSinkMap
protected java.util.HashSet _nodes
| Constructor Detail |
|---|
public BasicGraph()
public BasicGraph(int nodeCount)
public BasicGraph(java.util.Collection nodes)
public BasicGraph(BasicGraph graph)
| Method Detail |
|---|
public void addNode(java.lang.Object node)
public void addNodes(java.util.Collection nodes)
public boolean addEdge(Edge edge)
edge - The Edge object to add
public java.lang.Object clone()
clone in class java.lang.Objectpublic boolean containsNode(java.lang.Object o)
DirectedGraph
containsNode in interface DirectedGrapho - Object to test for graph inclusion.
public Edge getEdge(java.lang.Object source,
java.lang.Object sink)
TODO: What if there are multiple edges for the same source and sink?
getEdge in interface DirectedGraph
public java.util.Collection<? extends Edge> getEdges(java.lang.Object source,
java.lang.Object sink)
public java.util.Collection<? extends Edge> getEdges()
DirectedGraph
getEdges in interface DirectedGraphpublic java.util.Collection getInputEdges(java.lang.Object node)
getInputEdges in interface DirectedGraphDirectedGraph.getInputEdges(Object)public java.util.Collection getNodes()
getNodes in interface DirectedGraphpublic java.util.Collection getNodesWithNoInputEdges()
public java.util.Collection getNodesWithNoOutputEdges()
public java.util.Collection getOutputEdges(java.lang.Object node)
getOutputEdges in interface DirectedGraphpublic java.util.Collection getSinkNodes()
public java.util.Collection getSourceNodes()
public BasicGraph getSubGraph(java.util.Collection nodeCollection)
getSubGraph in interface DirectedGraphpublic BasicGraph getSubGraph2(java.util.Collection nodes)
public DirectedGraph invert()
invert in interface DirectedGraphpublic void removeEdges(java.util.Collection edges)
public boolean removeEdge(Edge edge)
edge - The Edge object to remove
public void removeNode(java.lang.Object node)
node - The node Object to remove
public void removeNode(java.lang.Object node,
boolean removeAllEdges)
node - The node Object to removeremoveAllEdges - If true, removes ALL Edges that refer to this node,
not just the ones mapped from this node (the easy-to-get-to Edges). In
other words, true removes ALL references to this node, while false may
leave some Edges that refer to this node.public static java.util.List topologicalSort(AbstractEdifGraph graph)
graph - The acyclic AbstractEdifGraph to sort
EdifRuntimeException - In the case of a cyclic graph
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||