public class BIFParser extends java.lang.Object implements GraphConstants
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
graphName
This holds the name of the graph (i.e. the name of network tag in XMLBIF
input)
|
protected java.io.InputStream |
inStream
This holds the InputStream to be parsed
|
protected java.lang.String |
inString
This holds the string to be parsed
|
protected java.util.ArrayList<GraphEdge> |
m_edges |
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 |
|---|
BIFParser(java.io.InputStream instream,
java.util.ArrayList<GraphNode> nodes,
java.util.ArrayList<GraphEdge> edges)
Constructor (if our input is an InputStream)
|
BIFParser(java.lang.String input,
java.util.ArrayList<GraphNode> nodes,
java.util.ArrayList<GraphEdge> edges)
Constructor (if our input is a String)
|
| Modifier and Type | Method and Description |
|---|---|
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
|
static void |
writeXMLBIF03(java.lang.String filename,
java.lang.String graphName,
java.util.ArrayList<GraphNode> nodes,
java.util.ArrayList<GraphEdge> edges)
This method writes a graph in XMLBIF ver. 0.3 format to a file.
|
protected java.util.ArrayList<GraphNode> m_nodes
protected java.util.ArrayList<GraphEdge> m_edges
protected java.lang.String graphName
protected java.lang.String inString
protected java.io.InputStream inStream
public BIFParser(java.lang.String input,
java.util.ArrayList<GraphNode> nodes,
java.util.ArrayList<GraphEdge> edges)
input - the string to be parsed (should not be null)nodes - vector containing GraphNode objects (should be empty)edges - vector containing GraphEdge objects (should be empty)public BIFParser(java.io.InputStream instream,
java.util.ArrayList<GraphNode> nodes,
java.util.ArrayList<GraphEdge> edges)
instream - the InputStream to be parsed (should not be null)nodes - vector containing GraphNode objects (should be empty)edges - vector containing GraphEdge objects (should be empty)public java.lang.String parse()
throws java.lang.Exception
java.lang.Exception - if both the inString and inStream are null, i.e. no
input has been providedBIFFormatException - if there is format of the input is not
correct. The format should conform to XMLBIF version 0.3java.lang.NumberFormatException - if there is an invalid char in the
probability table of a node.public static void writeXMLBIF03(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 graph. (will be the name of network tag in
XMLBIF)nodes - Vector containing all the nodesedges - Vector containing all the edges