public class DotParser extends java.lang.Object implements GraphConstants
| Modifier and Type | Field and Description |
|---|---|
protected java.util.ArrayList<GraphEdge> |
m_edges |
protected java.lang.String |
m_graphName
This holds the name of the graph if there is any otherwise it is null
|
protected java.io.Reader |
m_input
This is the input containing DOT stream to be parsed
|
protected java.util.ArrayList<GraphNode> |
m_nodes
These holds the nodes and edges of the graph
|
DIRECTED, DOUBLE, NORMAL, PLURAL_DUMMY, REVERSED, SINGULAR_DUMMY| Constructor and Description |
|---|
DotParser(java.io.Reader input,
java.util.ArrayList<GraphNode> nodes,
java.util.ArrayList<GraphEdge> edges)
Dot parser Constructor
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
edgeAttrib(java.io.StreamTokenizer tk,
GraphEdge e) |
protected void |
edgeStmt(java.io.StreamTokenizer tk,
int nindex) |
protected void |
graph(java.io.StreamTokenizer tk)
Following methods parse the DOT input and mimic the DOT language's grammar
in their structure
|
protected void |
nodeID(java.io.StreamTokenizer tk) |
protected void |
nodeStmt(java.io.StreamTokenizer tk,
int nindex) |
java.lang.String |
parse()
This method parses the string or the InputStream that we passed in through
the constructor and builds up the m_nodes and m_edges vectors
|
protected void |
setSyntax(java.io.StreamTokenizer tk)
This method sets the syntax of the StreamTokenizer. i.e. set the
whitespace, comment and delimit chars.
|
protected void |
stmt(java.io.StreamTokenizer tk) |
protected void |
stmtList(java.io.StreamTokenizer tk) |
static void |
writeDOT(java.lang.String filename,
java.lang.String graphName,
java.util.ArrayList<GraphNode> nodes,
java.util.ArrayList<GraphEdge> edges)
This method saves a graph in a file in DOT format.
|
protected java.util.ArrayList<GraphNode> m_nodes
protected java.util.ArrayList<GraphEdge> m_edges
protected java.io.Reader m_input
protected java.lang.String m_graphName
public DotParser(java.io.Reader input,
java.util.ArrayList<GraphNode> nodes,
java.util.ArrayList<GraphEdge> edges)
input - - The input, if passing in a string then encapsulate that in
String reader objectnodes - - Vector to put in GraphNode objects, corresponding to the
nodes parsed in from the inputedges - - Vector to put in GraphEdge objects, corresponding to the
edges parsed in from the inputpublic java.lang.String parse()
protected void setSyntax(java.io.StreamTokenizer tk)
protected void graph(java.io.StreamTokenizer tk)
protected void stmtList(java.io.StreamTokenizer tk)
throws java.lang.Exception
java.lang.Exceptionprotected void stmt(java.io.StreamTokenizer tk)
protected void nodeID(java.io.StreamTokenizer tk)
throws java.lang.Exception
java.lang.Exceptionprotected void nodeStmt(java.io.StreamTokenizer tk,
int nindex)
throws java.lang.Exception
java.lang.Exceptionprotected void edgeStmt(java.io.StreamTokenizer tk,
int nindex)
throws java.lang.Exception
java.lang.Exceptionprotected void edgeAttrib(java.io.StreamTokenizer tk,
GraphEdge e)
throws java.lang.Exception
java.lang.Exceptionpublic static void writeDOT(java.lang.String filename,
java.lang.String graphName,
java.util.ArrayList<GraphNode> nodes,
java.util.ArrayList<GraphEdge> edges)
filename - - The name of the file to write in. (will overwrite)graphName - - The name of the graphnodes - - Vector containing all the nodesedges - - Vector containing all the edges