public class DotParser extends Object implements GraphConstants
Modifier and Type | Field and Description |
---|---|
protected FastVector |
m_edges
These holds the nodes and edges of the graph
|
protected String |
m_graphName
This holds the name of the graph if there is any otherwise it is null
|
protected Reader |
m_input
This is the input containing DOT stream to be parsed
|
protected FastVector |
m_nodes
These holds the nodes and edges of the graph
|
DIRECTED, DOUBLE, NORMAL, PLURAL_DUMMY, REVERSED, SINGULAR_DUMMY
Constructor and Description |
---|
DotParser(Reader input,
FastVector nodes,
FastVector edges)
Dot parser Constructor
|
Modifier and Type | Method and Description |
---|---|
protected void |
edgeAttrib(StreamTokenizer tk,
GraphEdge e) |
protected void |
edgeStmt(StreamTokenizer tk,
int nindex) |
protected void |
graph(StreamTokenizer tk)
Following methods parse the DOT input and mimic the DOT
language's grammar in their structure
|
protected void |
nodeID(StreamTokenizer tk) |
protected void |
nodeStmt(StreamTokenizer tk,
int nindex) |
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(StreamTokenizer tk)
This method sets the syntax of the StreamTokenizer.
|
protected void |
stmt(StreamTokenizer tk) |
protected void |
stmtList(StreamTokenizer tk) |
static void |
writeDOT(String filename,
String graphName,
FastVector nodes,
FastVector edges)
This method saves a graph in a file in DOT format.
|
protected FastVector m_nodes
protected FastVector m_edges
protected Reader m_input
protected String m_graphName
public DotParser(Reader input, FastVector nodes, FastVector 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 String parse()
protected void setSyntax(StreamTokenizer tk)
protected void graph(StreamTokenizer tk)
protected void stmtList(StreamTokenizer tk) throws Exception
Exception
protected void stmt(StreamTokenizer tk)
protected void nodeID(StreamTokenizer tk) throws Exception
Exception
protected void nodeStmt(StreamTokenizer tk, int nindex) throws Exception
Exception
protected void edgeStmt(StreamTokenizer tk, int nindex) throws Exception
Exception
protected void edgeAttrib(StreamTokenizer tk, GraphEdge e) throws Exception
Exception
public static void writeDOT(String filename, String graphName, FastVector nodes, FastVector 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 edgesCopyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.