|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectspiglet.translate.graph.Graph
public abstract class Graph
This abstract class defines the public API and default implementation of the primitive functions of both types of graphs (control flow and interference graphs) we are going to use in this module.
Node
Field Summary | |
---|---|
protected java.util.List<Node> |
nodes
The list of all nodes in the graph. |
Constructor Summary | |
---|---|
Graph()
|
Method Summary | |
---|---|
boolean |
addEdge(Node from,
Node to)
Adds a directed edge between the two given nodes. |
boolean |
addNode(Node n)
Adds the given node to the graph. |
protected void |
check(Node node)
Helper function that simply checks if the given node belongs to this graph. |
Node |
createNode()
Creates a node that is associated to this graph, then return it. |
java.util.List<Node> |
getNodes()
Returns the (unmodifiable) list of all the nodes defined in this graph. |
boolean |
removeEdge(Node from,
Node to)
Removes a directed edge from the two given nodes. |
java.lang.String |
toString()
Returns the string representation of this graph, for debugging dump. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.List<Node> nodes
Constructor Detail |
---|
public Graph()
Method Detail |
---|
public java.util.List<Node> getNodes()
public Node createNode()
addNode(spiglet.translate.graph.Node)
.
public boolean addNode(Node n)
n
- the node to add
true
if the operation succeeds, false
otherwise
(the node already exists).public boolean addEdge(Node from, Node to)
Node
in the neighbor Nodes
'
"neighbor" fields.
from
- the node whence the edge comesto
- the node where to the edge arrive
true
if the operation succeeds, false
otherwise (the edge already exists)public boolean removeEdge(Node from, Node to)
false
if
no such edge exists to begin with.
This abstract class defines a default implementation that assumes edges
are represented by references to neighbor nodes in each Node
.
from
- the node whence the edge comesto
- the node where to the edge arrive
true
if the operation succeeds, false
otherwise (the edge does not exist)protected void check(Node node)
node
- the node to checkpublic java.lang.String toString()
({#,#,...,#,}, {(#,#),(#,#),...,(#,#),})
, which represents
the set of nodes and edges in the graph, where each node is represented
by its key number.
This default implementation relies on the information from
Node.getPredecessors()
and Node.getSuccessors()
.
Override the method if edges are represented differently.
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |