|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.unipi.di.graph.GraphLabelerConfig
public class GraphLabelerConfig
Configuration class for a GraphLabeler
. Objects of this class
are used to store information about how the vertex labels and
the edge-attributes values are stored on disk.
Once a configuration is defined, it can be saved in a permanent way
in a text file using the method store(String)
. A previous
configuration can be loaded using
the static method load(String)
. The configuration file is
written in a text form and can be easily modified with a text editor.
TextDB
. A TextDB stores on disk
a textual file in a compressed way and offers fast access to its
records (i.e. lines, and thus labels)
without the need to uncompress the entire file. Among all implementations of a TextDB,
the programmer can choose the one that best fits the type of vertex labels. Then one
can invoke a build method, or issue
it from the command line. Once the build stage
is complete the plain textual file can be thrown away.
setVertexDB(Range, TextDB)
to tie this TextDB
with its vertex subrange.setEdgeDB(String, TextDB)
it is possible to define an attribute (name) and declare
the TextDB object used to access the values of that attribute. As in the case of vertex labels,
the attribute values are stored on disk and
accessed using a TextDB. This means that first a textual file containing the attribute values
must be built, and then a (proper) TextDB has to be constructed on this file. Once the building
stage is over, the plain textual file can be thrown away.
load(String)
method. The syntax to use is
simple and intuitive. For instance, suppose to have two label ranges [0, 99] and [100, 199]
for a graph of 200 vertices and two edge attributes, namely "weight" and "color". Suppose to
store that informations in four TextDBs stored respectively into the files "label0.tdb",
"labels1.tdb", "weight.tdb" and "color.tdb". Then the configuration file will be:
[0, 99]: label0.tdb
[100, 199]: label1.tdb
weight: weight.tdb
color: color.tdb
The first two lines defines two vertex ranges through the usual syntax [i, j]
and
bind to them the TextDBs storing its labels. The same happens in the last two lines, but
the values stored in the referred TextDBs are the values of the edge attributes "weight" and
"color". Note that range definitions and edge attribute names are separated from the TextDB
file name by a ":" character. Remember also that the defined ranges cannot be overlapping and
the attribute names must be unique.
Field Summary | |
---|---|
protected SortedMap<String,TextDB> |
edges
|
protected SortedMap<Range,TextDB> |
vertices
|
Constructor Summary | |
---|---|
GraphLabelerConfig()
Creates a new configuration. |
Method Summary | |
---|---|
boolean |
attributeAlreadyDefined(String attribute)
Returns true if the given edge attribute has been already configured. |
void |
close()
Closes all the TextDBs in this configuration. |
Set<String> |
getEdgeAttributes()
Returns the available edge attributes defined in this configuration. |
TextDB |
getEdgeDB(String attribute)
Returns the TextDB storing the values of an edge attribute. |
SortedMap<Range,TextDB> |
getRangeDBMap(Range r)
Given an input range, this method collect all the Range/TextDB pairs for all the subranges defined in this configuration and contained in the input one. |
Range |
getRangeFor(int vertex)
Returns the range containing the input vertex, as defined in this configuration. |
Range |
getSpanningRange()
Returns the spanning range containing all the vertex ranges defined in this configuration. |
TextDB |
getVertexDB(int v)
Returns the TextDB associated to a vertex. |
TextDB[] |
getVertexDBs(Range r)
Returns the TextDBs covering the passed range. |
static GraphLabelerConfig |
load(String file)
Loads a configuration previously stored in a file. |
protected void |
open()
Opens all the TextDBs in this configuration. |
TextDB |
setEdgeDB(String attribute,
TextDB db)
Defines an edge attribute and its TextDB for accessing its values. |
void |
setVertexDB(int i,
int j,
TextDB db)
Sets a TextDB storing the labels for the vertices in the range [i, j]. |
void |
setVertexDB(Range r,
TextDB db)
Sets a TextDB storing the labels for the vertices in the given range. |
void |
setVertexDB(TextDB db)
Sets a TextDB storing the vertex labels. |
void |
store(String file)
Writes on a file the current configuration. |
boolean |
vertexRangeAlreadyDefined(int i,
int j)
Returns true if the range [i, j] has been already defined as vertex range in this configuration. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected SortedMap<Range,TextDB> vertices
protected SortedMap<String,TextDB> edges
Constructor Detail |
---|
public GraphLabelerConfig()
Method Detail |
---|
public boolean vertexRangeAlreadyDefined(int i, int j)
i
- lower bound of the rangej
- upper bound of the range
public boolean attributeAlreadyDefined(String attribute)
attribute
- the edge attribute to check
public void setVertexDB(int i, int j, TextDB db) throws IOException
i
- the lower bound of the rangej
- the upper bound of the rangedb
- the TextDB to associate to the range [i, j]
IOException
public void setVertexDB(TextDB db) throws IOException
db
-
IOException
public void setVertexDB(Range r, TextDB db) throws IOException
r
- a range of verticesdb
- the TextDB associated to the input range of vertices
IOException
public TextDB setEdgeDB(String attribute, TextDB db) throws IOException
attribute
- the edge attribute to definedb
- the TextDB used to access the values of this attribute
IOException
public TextDB[] getVertexDBs(Range r)
r
- a range
public SortedMap<Range,TextDB> getRangeDBMap(Range r)
r
- the input range
public TextDB getVertexDB(int v)
v
- the vertex id
public Range getRangeFor(int vertex)
vertex
- the input vertex
public Range getSpanningRange()
public TextDB getEdgeDB(String attribute)
attribute
- the attribute name
public void store(String file) throws IOException
file
- the output file
IOException
public static GraphLabelerConfig load(String file) throws IOException
file
- the configuration file to load
IOException
protected void open() throws IOException
IOException
public void close() throws IOException
IOException
public Set<String> getEdgeAttributes()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |