|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbyucc.jhdl.synth.graph.NamedObject
byucc.jhdl.synth.graph.Graph
Basic object for representing graphs. It is intended that users will extend this class for implementing any user-specific graph annotations or features.
Field Summary | |
protected int |
printNum
To help printing a graph multiple times, during debugging an algorithm that modifies the graph regularly,etc |
protected VertexVector |
vertexVector
This vector contains all vertices in the graph. |
Fields inherited from class byucc.jhdl.synth.graph.NamedObject |
name |
Constructor Summary | |
Graph()
Default constructor. |
|
Graph(java.lang.String name)
Construct a named graph. |
Method Summary | |
Edge |
addEdge(Edge edge)
Adds an Edge to the graph using an existing Edge object. |
Edge |
addEdge(Vertex tail,
Vertex head)
Adds an Edge to the graph (tailVertex -> headVertex). |
Vertex |
addVertex(java.lang.String name)
Adds a named vertex to the graph. |
Vertex |
addVertex(Vertex v)
|
Edge |
getEdge(Vertex tail,
Vertex head)
Get the edge going from tail to head, (or null if no edge goes from tail to edge). |
EdgeIterator |
getEdges()
Get a GenericIterator of all the edges in the graph. |
static java.io.PrintWriter |
getPrintWriter(java.lang.String fileName)
|
IndexedVertexIterator |
getVertices()
Get a list of all the vertices in the graph. |
boolean |
hasEdge(Edge edge)
Does this graph contain the given edge |
boolean |
hasEdge(Vertex tail,
Vertex head)
Does this graph contain an edge from tail -> head |
boolean |
hasVertex(Vertex vertex)
Does this graph contain the given vertex |
void |
mergeVertices(Vertex A,
Vertex B)
Merge two vertices. |
protected Edge |
newEdge(Vertex tail,
Vertex head)
This method will create the appropriate vertex for the graph. |
protected Vertex |
newVertex(java.lang.String name)
This method will create the appropriate vertex for the graph. |
void |
printGraph()
Every call of printGraph wld print a new graph with the name incremented each time |
static void |
printGraph(Graph g)
static method that cld used from outside to print a Graph |
static void |
printGraph(Graph g,
java.lang.String fname)
a filename can be specified where the output shd go |
void |
printGraph(java.lang.String outputName)
|
static void |
removeEdge(Edge edge)
Removes an Edge from the graph using an existing Edge object. |
void |
removeEdge(Vertex tail,
Vertex head)
Removes an Edge from the graph. |
void |
removeVertex(Vertex vertex)
Removes a Vertex from the graph, as well as all edges associated with the Vertex. |
void |
resetVisited()
Reset the visited flag for all vertices in the graph. |
void |
setEdgeProperty(Edge e,
java.lang.String key,
java.lang.String value)
|
void |
setVertexProperty(Vertex v,
java.lang.String key,
java.lang.String value)
|
java.lang.StringBuffer |
toDot()
Create a representation of this graph in the IBM dotty file format. |
java.lang.StringBuffer |
toDot(java.lang.StringBuffer s)
Create a representation of this graph in the IBM dotty file format. |
java.lang.String |
toString()
Get a String representation of this graph. |
Methods inherited from class byucc.jhdl.synth.graph.NamedObject |
getName, setName |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected VertexVector vertexVector
protected int printNum
Constructor Detail |
public Graph()
public Graph(java.lang.String name)
name
- the name for the graphMethod Detail |
public final Vertex addVertex(java.lang.String name)
name
- The name for the new vertex
public final Vertex addVertex(Vertex v)
public void mergeVertices(Vertex A, Vertex B)
This merge is implemented by copying all input and output edges from vertex B to vertex A. That is, all edges of the form ?->B will be replaced with ?->A and all edges B->? will be replaced with A->?. (Actually, if any of these new edges already exist on A they will not be duplicated.) Then vertex B will be removed from the graph.
A
- one of the vertices to be merged, this vertex will still be in
the graph after the merge.B
- another vertex to be merged, this vertex will be removed from the
graph after the merge.protected Vertex newVertex(java.lang.String name)
public void removeVertex(Vertex vertex)
vertex
- The Vertex to remove from the graph.public final Edge addEdge(Vertex tail, Vertex head)
tail
- The vertex corresponding to the tail of the Edge (i.e. the
source of the edge)head
- The vertex corresponding to the head of the Edge (i.e. the
sink of the edge)
newEdge(byucc.jhdl.synth.graph.Vertex, byucc.jhdl.synth.graph.Vertex)
public Edge addEdge(Edge edge)
edge
- A valid edge object with tail and head
Vertex objects that already exist in the graph.
public final void removeEdge(Vertex tail, Vertex head)
tail
- The vertex corresponding to the tail of the edge to remove.head
- The vertex corresponding to the head of the edge to remove.public static final void removeEdge(Edge edge)
edge
- The edge to be removed. A valid Edge object with tail and head Vertex objects that exist in the graph.protected Edge newEdge(Vertex tail, Vertex head)
tail
- The vertex corresponding to the tail of the Edge (i.e. the
source of the edge)head
- The vertex corresponding to the head of the Edge (i.e. the
sink of the edge)
public Edge getEdge(Vertex tail, Vertex head)
tail
- The vertex at the tail of the desired edgehead
- The vertex at the head of the desired edge
public EdgeIterator getEdges()
public IndexedVertexIterator getVertices()
public boolean hasEdge(Vertex tail, Vertex head)
tail
- the tail of the edge to look for.head
- the head of the edge to look for.
public boolean hasEdge(Edge edge)
edge
- the edge to look for.
public boolean hasVertex(Vertex vertex)
vertex
- the vertex to look for
public void resetVisited()
Vertex.resetVisit()
public java.lang.String toString()
toString
in class NamedObject
toDot()
public final java.lang.StringBuffer toDot()
public final java.lang.StringBuffer toDot(java.lang.StringBuffer s)
s
- The StringBuffer onto which data should be appendedpublic void setVertexProperty(Vertex v, java.lang.String key, java.lang.String value)
public void setEdgeProperty(Edge e, java.lang.String key, java.lang.String value)
public void printGraph()
public void printGraph(java.lang.String outputName)
public static void printGraph(Graph g)
public static void printGraph(Graph g, java.lang.String fname)
public static java.io.PrintWriter getPrintWriter(java.lang.String fileName)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |