|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.unipi.di.graph.GraphLabeler
public class GraphLabeler
A graph labeler for vertices and edges.
The graph is represented as a list of N vertices identified by integers in the
range [0, N-1] and a list of edges identified by the two vertices they connect.
Each vertex can be associated with a textual label, and each edge can
be associated with one or more textual attributes, each identified by a
unique name. This class offers access to these informations by means of a
GraphLabelerConfig
object, which defines how the labels and the
attribute values are stored on disk. Concrete access to these data is implemented
by means of the TextDB
interface.
We note that the structure of the graph, namely its vertices and edges, is
not stored in this class.
GraphLabelerConfig
,
TextDB
Constructor Summary | |
---|---|
GraphLabeler(GraphLabelerConfig conf)
Create a new GraphLabeler using the provided configuration. |
Method Summary | |
---|---|
void |
close()
Closes the labeler and releases all the resources associated to it. |
GraphLabelerConfig |
getConfig()
Returns the current configuration. |
String |
getEdgeAttribute(int v,
int rank,
String attribute)
Returns the attribute value of an edge. |
String[] |
getOutgoingAttribute(int vertex,
String attribute)
Returns the attribute values defined for the outgoing edges starting from a vertex. |
String |
getVertexLabel(int v)
Returns the label associated to the input vertex, or null if the label is not defined. |
String[] |
getVertexLabels(int[] vertices)
Returns the labels for a sorted list of vertices. |
String[] |
getVertexLabels(int[] vertices,
int offset,
int length)
Returns the labels for a sorted list of vertices. |
String[] |
getVertexLabels(int i,
int j)
Returns the labels for the vertices in range [i, j]
(bounds included). |
String |
getVertexType(int v)
Returns a String object identifying the type of a vertex. |
static GraphLabeler |
load(String confFile)
Create a new GraphLabeler loading its configuration from a textual file. |
static void |
main(String[] args)
|
String[] |
splitAttributeValues(String attribute,
String sep)
Given a multi-value attribute, this method returns its individual values in an array of strings. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GraphLabeler(GraphLabelerConfig conf) throws IOException
conf
- the configuration defining the data sources.
IOException
Method Detail |
---|
public static GraphLabeler load(String confFile) throws IOException
confFile
- the name of the configuration file
IOException
GraphLabelerConfig.load(String)
public GraphLabelerConfig getConfig()
public void close() throws IOException
IOException
public String getVertexLabel(int v) throws IOException
v
- vertex id.
IOException
- if some I/O error occur.
ArrayIndexOutOfBoundsException
- if the requested vertex is outside the current configuration.public String[] getVertexLabels(int i, int j) throws IOException
[i, j]
(bounds included). The returned array will has the same length
of the passed range. The array will contains null references
for vertices not defined in this
labeler. The requested range must be positive with a lower bound greater or equals than
zero and an upper bound no bigger than the defined maximum position for this labeler.
The bounds are checked by this method and an ArrayIndexOutOfBoundsException
will be thrown in case the bounds doesn't respect such limits.
i
- the lower bound of the range.j
- the upper bound of the range.
[i, j]
.
IOException
- if some I/O errors occur.
ArrayIndexOutOfBoundsException
- in case the requested ids are out of the bounds
defined in the current configuration.GraphLabelerConfig.getSpanningRange()
public String[] getVertexLabels(int[] vertices) throws IOException
vertices
- sorted list of vertex ids.
IOException
- if some I/O errors occur.
ArrayIndexOutOfBoundsException
- in case the requested ids are out of the bounds
defined in the current configuration.public String[] getVertexLabels(int[] vertices, int offset, int length) throws IOException
offset
to
length-1
. A ArrayIndexOutOfBoundsException
will be
thrown if the input vertex ids are out of the bounds of the current configuration.
vertices
- sorted list of vertex ids (at least in the positions from 0
to length
).offset
- the starting position of the input array.length
- the number of positions to consider in the passed array starting
from 0. Must be non negative.
IOException
- if some I/O errors occur.
ArrayIndexOutOfBoundsException
- in case the requested ids are out of the bounds
defined in the current configuration.GraphLabelerConfig.getSpanningRange()
public String getVertexType(int v) throws IOException
TextDB
storing the vertex label determines
the type of the vertex. Two vertices with labels stored into the same TextDB
will result of the same type.
v
- a vertex ID
IOException
TextDB.getName()
public String getEdgeAttribute(int v, int rank, String attribute) throws IOException
v
- source vertex of the edgerank
- the rank of the target node defining the edge among
the neighbors of vattribute
- the attribute name
IOException
getOutgoingAttribute(int, String)
public String[] getOutgoingAttribute(int vertex, String attribute) throws IOException
vertex
- the starting vertexattribute
- the name of the attribute to extract from the outgoing edges
IOException
public String[] splitAttributeValues(String attribute, String sep)
TextDB.getFieldValues(String, String)
.
attribute
- the attribute to be parsedsep
- the character-sequence used to separate the values in the input attribute
public static void main(String[] args) throws Exception
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |