Class Graph
java.lang.Object
EDU.purdue.cs.bloat.util.Graph
- Direct Known Subclasses:
FlowGraph
Graph represents a graph of nodes with directed edges between them.
GraphNodes are created and are added to the Graph before the edges can be
constructed. Each GraphNode as a unique key associated with it. For instance,
if a Graph represents a control flow graph, each GraphNode would be
associated with a basic block.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected intprotected intprotected intprotected intprotected int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a directed edge from node v to node w.voidInsertes a node (and its associated key) into this Graph.Returns the node in this Graph with a given key.booleanSearches this Graph for an (directed) edge between two GraphNodes.booleanSearchs this Graph for a given GraphNode.booleanDetermines whether or not a node v is an ancestor (has a lower pre-order index and a higher post-order index) of a node w.keySet()Returns a Set of the keys used to uniquely identify the nodes in this Graph.nodes()Returns all the nodes in this Graph.Return the nodes in this Graph ordered by their post-order index.intpostOrderIndex(GraphNode node) Returns the index of a given node in a post-order ordering of this Graph.Returns the predacessors of a given node.preOrder()Returns the nodes in this Graph ordered by their pre-order index.intpreOrderIndex(GraphNode node) Returns the index of a given node in a pre-order ordering of this Graph.voidremoveEdge(GraphNode v, GraphNode w) voidremoveNode(Object key) Removes a node with a given key from the Graph.voidRemoves all nodes from this Graph that cannot be reached in a pre-order traversal of the Graph.roots()intsize()Returns the number of nodes in this Graph.Return the successors of a given node.toString()
-
Field Details
-
rootEdgeModCount
protected int rootEdgeModCount -
revRootEdgeModCount
protected int revRootEdgeModCount -
nodeModCount
protected int nodeModCount -
edgeModCount
protected int edgeModCount -
removingNode
protected int removingNode -
removingEdge
protected int removingEdge
-
-
Constructor Details
-
Graph
public Graph()Constructor.
-
-
Method Details
-
roots
- Returns:
- The roots of this Graph. That is, the nodes with no predacessors.
-
reverseRoots
- Returns:
- The reverse roots of this Graph. That is, the nodes with no successors.
-
succs
Return the successors of a given node. -
preds
Returns the predacessors of a given node. -
isAncestorToDescendent
-
preOrderIndex
Returns the index of a given node in a pre-order ordering of this Graph. -
postOrderIndex
Returns the index of a given node in a post-order ordering of this Graph. -
preOrder
Returns the nodes in this Graph ordered by their pre-order index. -
postOrder
Return the nodes in this Graph ordered by their post-order index. -
removeUnreachable
public void removeUnreachable()Removes all nodes from this Graph that cannot be reached in a pre-order traversal of the Graph. These nodes have a pre-order index of -1. -
addNode
-
getNode
-
keySet
Returns a Set of the keys used to uniquely identify the nodes in this Graph. -
removeNode
Removes a node with a given key from the Graph.- Parameters:
key- The key associated with the node to remove.
-
addEdge
-
removeEdge
-
toString
-
hasNode
Searchs this Graph for a given GraphNode.- Parameters:
v- GraphNode to search for.- Returns:
- True, if this Graphs contains v.
-
hasEdge
-
nodes
Returns all the nodes in this Graph. -
size
public int size()Returns the number of nodes in this Graph.
-