|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.uci.ics.jung.io.PajekNetReader
public class PajekNetReader
Reads a Graph from a Pajek NET formatted source.
If the edge constraints specify that the graph is strictly undirected,
and an "*Arcs" section is encountered, or if the edge constraints specify that the
graph is strictly directed, and an "*Edges" section is encountered,
an IllegalArgumentException is thrown.
If the edge constraints do not permit parallel edges, only the first encountered of a set of parallel edges will be read; subsequent edges in that set will be ignored.
More restrictive edge constraints will cause vertices to be generated that are more time- and space-efficient.
At the moment, only supports the part of the specification that defines:
Here is an example format for a directed graph without edge weights
and edges specified in list form:
*vertices <# of vertices> 1 "a" 2 "b" 3 "c" *arcslist 1 2 3 2 3Here is an example format for an undirected graph with edge weights and edges specified in non-list form:
*vertices <# of vertices> 1 "a" 2 "b" 3 "c" *edges 1 2 0.1 1 3 0.9 2 3 1.0
| Nested Class Summary | |
|---|---|
protected static class |
PajekNetReader.ListTagPred
A Predicate which evaluates to true if the
argument ends with the string "list". |
protected static class |
PajekNetReader.TagPred
A Predicate which evaluates to true if the
argument starts with the constructor-specified String. |
| Field Summary | |
|---|---|
protected boolean |
get_locations
|
protected static Predicate |
l_pred
|
static String |
LABEL
The key used to identify the vertex labels (if any) created by this class. |
static String |
LOCATIONS
The user data key used to retrieve the vertex locations (if any) defined by this class. |
protected static Predicate |
p_pred
|
protected boolean |
unique_labels
|
protected SettableVertexLocationFunction |
v_locations
|
| Constructor Summary | |
|---|---|
PajekNetReader()
Creates a PajekNetReader whose labels are not required to be unique. |
|
PajekNetReader(boolean unique_labels)
Creates a PajekNetReader with the specified labeling behavior, which does not read location information (if any). |
|
PajekNetReader(boolean unique_labels,
boolean get_locations)
Creates a PajekNetReader with the specified labeling behavior and location assignment behavior. |
|
PajekNetReader(boolean unique_labels,
SettableVertexLocationFunction v_locations)
Creates a PajekNetReader with the specified labeling behavior and location assignment behavior. |
|
| Method Summary | |
|---|---|
protected Edge |
createAddEdge(StringTokenizer st,
Vertex v1,
boolean directed,
Graph g,
Indexer id,
boolean parallel_ok)
|
Graph |
load(Reader reader)
Returns load(reader, new SparseGraph(), null). |
Graph |
load(Reader reader,
Graph g)
Returns load(reader, g, null). |
Graph |
load(Reader reader,
Graph g,
NumberEdgeValue nev)
Returns load(reader, g, nev, new TypedVertexGenerator(g)). |
Graph |
load(Reader reader,
Graph g,
NumberEdgeValue nev,
VertexGenerator vg)
Populates the graph g with the graph represented by the
Pajek-format data supplied by reader. |
Graph |
load(Reader reader,
NumberEdgeValue nev)
Returns load(reader, new SparseGraph(), nev). |
Graph |
load(String filename)
Returns load(filename, new SparseGraph(), null). |
Graph |
load(String filename,
Graph g)
Returns load(filename, g, null). |
Graph |
load(String filename,
Graph g,
NumberEdgeValue nev)
Creates a FileReader from filename, calls
load(reader, g, nev), closes the reader, and returns
the resultant graph. |
Graph |
load(String filename,
NumberEdgeValue nev)
Returns load(filename, new SparseGraph(), nev). |
void |
setGetLocations(boolean get_locations)
Sets or clears the get_locations boolean. |
void |
setUniqueLabels(boolean unique_labels)
Sets or clears the unique_labels boolean. |
protected String |
skip(BufferedReader br,
Predicate p)
Returns the first line read from br for which p
returns true, or null if there is no
such line. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean unique_labels
public static final String LABEL
public static final String LOCATIONS
protected SettableVertexLocationFunction v_locations
protected boolean get_locations
protected static final Predicate l_pred
protected static final Predicate p_pred
| Constructor Detail |
|---|
public PajekNetReader(boolean unique_labels)
PajekNetReader(boolean, boolean)
public PajekNetReader(boolean unique_labels,
boolean get_locations)
If unique_labels is true, vertices will be labelled
using a StringLabeller with key jung.io.PajekNetReader.LABEL.
Otherwise, they will be labeled with a user data String with key
PajekNetReader.LABEL. (Vertices that have no apparent label
information will not be labelled.)
If get_locations is true, each vertex line in the file
will be assumed to contain (x,y) coordinates in the range [0,1]; if any line
lacks this data, an IllegalArgumentException will be thrown. (The Pajek
format assumes coordinates are (x,y,z) but we ignore the z-coordinate.) Location
data will be stored in a SettabelVertexLocationDecorator instance
in the graph's user data with keyjung.io.PajekNetReader.LOCATIONS.
public PajekNetReader(boolean unique_labels,
SettableVertexLocationFunction v_locations)
If unique_labels is true, vertices will be labelled
using a StringLabeller with key jung.io.PajekNetReader.LABEL.
Otherwise, they will be labeled with a user data String with key
PajekNetReader.LABEL. (Vertices that have no apparent label
information will not be labelled.)
If get_locations is true, each vertex line in the file
will be assumed to contain (x,y) coordinates in the range [0,1]; if any line
lacks this data, an IllegalArgumentException will be thrown. (The Pajek
format assumes coordinates are (x,y,z) but we ignore the z-coordinate.) Location
data will be stored in v_locations, a reference to which will be
stored in the graph's user data with key jung.io.PajekNetReader.LOCATIONS.
public PajekNetReader()
| Method Detail |
|---|
public Graph load(String filename)
throws IOException
load(filename, new SparseGraph(), null).
IOException
public Graph load(String filename,
NumberEdgeValue nev)
throws IOException
load(filename, new SparseGraph(), nev).
IOException
public Graph load(String filename,
Graph g)
throws IOException
load(filename, g, null).
IOException
public Graph load(String filename,
Graph g,
NumberEdgeValue nev)
throws IOException
FileReader from filename, calls
load(reader, g, nev), closes the reader, and returns
the resultant graph.
IOException
public Graph load(Reader reader,
Graph g)
throws IOException
load(reader, g, null).
IOException
public Graph load(Reader reader,
NumberEdgeValue nev)
throws IOException
load(reader, new SparseGraph(), nev).
IOException
public Graph load(Reader reader)
throws IOException
load(reader, new SparseGraph(), null).
IOException
public Graph load(Reader reader,
Graph g,
NumberEdgeValue nev)
throws IOException
load(reader, g, nev, new TypedVertexGenerator(g)).
IOExceptionTypedVertexGenerator
public Graph load(Reader reader,
Graph g,
NumberEdgeValue nev,
VertexGenerator vg)
throws IOException
g with the graph represented by the
Pajek-format data supplied by reader. Stores edge weights,
if any, according to nev (if non-null).
Any existing vertices/edges of g, if any, are unaffected.
The edge data are filtered according to g's constraints, if any; thus, if
g only accepts directed edges, any undirected edges in the
input are ignored.
Vertices are created with the generator vg. The user is responsible
for supplying a generator whose output is compatible with this graph and its contents;
users that don't want to deal with this issue may use a TypedVertexGenerator
or call load(reader, g, nev) for a default generator.
IOException
protected Edge createAddEdge(StringTokenizer st,
Vertex v1,
boolean directed,
Graph g,
Indexer id,
boolean parallel_ok)
protected String skip(BufferedReader br,
Predicate p)
throws IOException
br for which p
returns true, or null if there is no
such line.
IOExceptionpublic void setUniqueLabels(boolean unique_labels)
unique_labels boolean.
PajekNetReader(boolean, boolean)public void setGetLocations(boolean get_locations)
get_locations boolean.
PajekNetReader(boolean, boolean)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||