public class BipartiteGraphReader
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected boolean |
asList
If
true , specifies that each line of input implicitly
represents a list of edges, where the first token specifies one endpoint,
and the subsequent tokens specify a sequence of opposite endpoints. |
protected boolean |
directed
If
true , the edges created
will be directed; otherwise, they will be undirected. |
protected boolean |
parallel
If
true , parallel edges may
be created if the edge is found more than once in the input file. |
static UserDatumVertexPredicate |
PART_A
The predicate for the vertices in partitions A and B.
|
static UserDatumVertexPredicate |
PART_B |
static java.lang.String |
PARTITION
The user data key for the vertices' partitions.
|
Constructor and Description |
---|
BipartiteGraphReader()
Creates a BipartiteGraphReader with default behavior (one edge per line,
undirected, no parallel edges created).
|
BipartiteGraphReader(boolean asList,
boolean directed,
boolean parallel) |
Modifier and Type | Method and Description |
---|---|
static org.apache.commons.collections.Predicate |
getPartition(Vertex v) |
boolean |
isAsList() |
boolean |
isDirected() |
boolean |
isParallel() |
KPartiteGraph |
load(java.io.Reader reader)
Creates a
KPartiteGraph (where k = 2) based on connection
data gathered from a Reader. |
void |
setAsList(boolean asList) |
void |
setDirected(boolean directed) |
void |
setParallel(boolean parallel) |
public static final java.lang.String PARTITION
public static final UserDatumVertexPredicate PART_A
public static final UserDatumVertexPredicate PART_B
protected boolean asList
If true
, specifies that each line of input implicitly
represents a list of edges, where the first token specifies one endpoint,
and the subsequent tokens specify a sequence of opposite endpoints.
Otherwise, each line of input represents a single edge.
protected boolean directed
If true
, the edges created
will be directed; otherwise, they will be undirected.
In either case, the graph is constrained to accept only the
specified edge type.
NOTE: Currently, the data format specified only permits directed edges whose source is in partition A and whose destination is in partition B.
protected boolean parallel
If true
, parallel edges may
be created if the edge is found more than once in the input file.
Otherwise, each edge is labelled with a weight by an
EdgeWeightLabeller
, and the graph is created with the
"no parallel edges" constraint.
The weight of each edge in the non-parallel case is the number of times
that the edge is represented in the input file (that is, the edge's multiplicity).
public BipartiteGraphReader(boolean asList, boolean directed, boolean parallel)
public BipartiteGraphReader()
public KPartiteGraph load(java.io.Reader reader) throws java.io.IOException
Creates a KPartiteGraph
(where k = 2) based on connection
data gathered from a Reader.
The data must be in one of the two following formats:
a_1 b_1 a_2 b_1 a_2 b_2 a_3 b_3 ...
or
a_1 b_1 b_2 b_3 a_2 b_2 b_3 a_3 b_3 ...
where x_i
is a unique label (ID) for vertex i
in partition x
. Each line in the file defines an edge
between the specified vertices. The vertices themselves are defined
implicitly: if a label is read from the file for which no vertex yet
exists, a new vertex is created and that label is attached to it.
The first format is the default; the second is assumed if the
asList
flag is set to true
. In
the default format, everything after the first whitespace is
interpreted as part of the label for the second vertex.
Vertex labels are only required to be unique within their
partitions. Each partition has its own StringLabeller
,
which is accessed via the key VID_A
or VID_B
,
as appropriate.
The end of the file may be artificially set by putting the string end_of_file
on a line by itself.
java.io.IOException
- May occur in the course of reading from a stream.public static org.apache.commons.collections.Predicate getPartition(Vertex v)
public void setAsList(boolean asList)
public void setDirected(boolean directed)
public void setParallel(boolean parallel)
public boolean isAsList()
public boolean isDirected()
public boolean isParallel()