public class BIFParser extends Object implements GraphConstants
Modifier and Type | Field and Description |
---|---|
protected String |
graphName
This holds the name of the graph (i.e.
|
protected InputStream |
inStream
This holds the InputStream to be parsed
|
protected String |
inString
This holds the string to be parsed
|
protected FastVector |
m_edges
These holds the nodes and edges of the graph
|
protected FastVector |
m_nodes
These holds the nodes and edges of the graph
|
DIRECTED, DOUBLE, NORMAL, PLURAL_DUMMY, REVERSED, SINGULAR_DUMMY
Constructor and Description |
---|
BIFParser(InputStream instream,
FastVector nodes,
FastVector edges)
Constructor (if our input is an InputStream)
|
BIFParser(String input,
FastVector nodes,
FastVector edges)
Constructor (if our input is a String)
|
Modifier and Type | Method and Description |
---|---|
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(String filename,
String graphName,
FastVector nodes,
FastVector edges)
This method writes a graph in XMLBIF ver.
|
protected FastVector m_nodes
protected FastVector m_edges
protected String graphName
protected String inString
protected InputStream inStream
public BIFParser(String input, FastVector nodes, FastVector 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(InputStream instream, FastVector nodes, FastVector 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 String parse() throws Exception
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.3NumberFormatException
- if there is an invalid
char in the probability table of a node.public static void writeXMLBIF03(String filename, String graphName, FastVector nodes, FastVector 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 edgesCopyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.