#include <GraphLoader.h>
Inheritance diagram for VGServer::GraphLoader:
Public Member Functions | |
void | addEdge (vertexid_t src, vertexid_t tgt) |
Creates or starts a new edge from the given src to tgt vertex ids. | |
void | addVertex (vertexid_t vid) |
Creates a new vertex with the given id. | |
GraphData & | finish () |
finish loading data, returns a reference to the enclosed GraphData. | |
GraphLoader (const class GraphProperties &gp) | |
create an initialized GraphLoader. | |
void | reserve (unsigned int vertexnum, unsigned int edgenum, unsigned int vertexattrsize, unsigned int edgeattrsize) |
reserve can be used to allocate enough space in the vertex, the edge, and the two attribute arrays. | |
void | setEdgeAttr (vertexid_t src, vertexid_t tgt, unsigned int attrid, const class AnyType &value) |
Sets the attribute of an edge. | |
void | setVertexAttr (vertexid_t vid, unsigned int attrid, const class AnyType &value) |
Sets the attribute of a vertex. | |
void | terminate () |
add the termination nodes, this will be called automaticly by finish(). |
Definition at line 15 of file GraphLoader.h.
VGServer::GraphLoader::GraphLoader | ( | const class GraphProperties & | gp | ) | [explicit] |
create an initialized GraphLoader.
Definition at line 12 of file GraphLoader.cc.
References VGServer::GraphData::edges, and VGServer::GraphData::vertices.
void VGServer::GraphLoader::addEdge | ( | vertexid_t | src, | |
vertexid_t | tgt | |||
) |
Creates or starts a new edge from the given src to tgt vertex ids.
Again this function is called from setEdgeAttr if the edge doesnt exist. The source vertex must already be loaded via addVertex().
Definition at line 232 of file GraphLoader.cc.
References VGServer::AttributePropertiesList::defbytes, VGServer::GraphProperties::edgeattr, VGServer::GraphData::edgeattr, VGServer::GraphData::edges, VGServer::GraphData::properties, VGServer::GraphData::Edge::target, VGServer::GraphData::vertices, and VGServer::TpAttributeBlob< AllocPolicy >::zero().
Referenced by VGServer::GraphLoaderKFile::load(), and setEdgeAttr().
void VGServer::GraphLoader::addVertex | ( | vertexid_t | vid | ) |
Creates a new vertex with the given id.
It is not strictly necessary to call this function as setVertexAttr will create a non-existing vertex.
Definition at line 74 of file GraphLoader.cc.
References VGServer::AttributePropertiesList::defbytes, VGServer::GraphData::properties, VGServer::GraphProperties::vertexattr, VGServer::GraphData::vertexattr, VGServer::GraphData::vertexcount, VGServer::GraphData::vertices, and VGServer::TpAttributeBlob< AllocPolicy >::zero().
Referenced by VGServer::GraphLoaderKFile::load(), and setVertexAttr().
class GraphData & VGServer::GraphLoader::finish | ( | ) |
finish loading data, returns a reference to the enclosed GraphData.
the reference should be applyGraph()-ed into a GraphContainer.
Definition at line 37 of file GraphLoader.cc.
References terminate(), and VGServer::VERTEX_INVALID.
void VGServer::GraphLoader::reserve | ( | unsigned int | vertexnum, | |
unsigned int | edgenum, | |||
unsigned int | vertexattrsize, | |||
unsigned int | edgeattrsize | |||
) |
reserve can be used to allocate enough space in the vertex, the edge, and the two attribute arrays.
This function need not be called, all arrays auto-grow. Any value may be 0 if it is unknown.
vertexnum | estimated vertex number of the graph | |
edgenum | estimated edges in the graph | |
vertexattrsize | size of packed vertex attributes in bytes | |
edgeattrsize | size of packed edge attributes in bytes |
Definition at line 27 of file GraphLoader.cc.
References VGServer::TpAttributeBlob< AllocPolicy >::alloc(), VGServer::GraphData::edgeattr, VGServer::GraphData::edges, VGServer::GraphData::vertexattr, and VGServer::GraphData::vertices.
void VGServer::GraphLoader::setEdgeAttr | ( | vertexid_t | src, | |
vertexid_t | tgt, | |||
unsigned int | attrid, | |||
const class AnyType & | value | |||
) |
Sets the attribute of an edge.
The vertex id pair need not exist, however vertex id pair _and_ attribute id can only be loaded in ascending order, otherwise an OrderException is thrown.
Definition at line 288 of file GraphLoader.cc.
References addEdge(), VGServer::ATTRTYPE_BOOL, VGServer::AnyType::convertType(), VGServer::GraphData::edgeattr, VGServer::GraphProperties::edgeattr, VGServer::AnyType::getInteger(), VGServer::AnyType::getValueLength(), VGServer::GraphData::properties, VGServer::TpAttributeBlob< AllocPolicy >::putAnyType(), and VGServer::TpAttributeBlob< AllocPolicy >::putBool().
Referenced by VGServer::GraphLoaderKFile::load().
void VGServer::GraphLoader::setVertexAttr | ( | vertexid_t | vid, | |
unsigned int | attrid, | |||
const class AnyType & | value | |||
) |
Sets the attribute of a vertex.
The vertex id need not exist, however vertex id _and_ attribute id can only be loaded in ascending order, otherwise an OrderException is thrown.
Definition at line 119 of file GraphLoader.cc.
References addVertex(), VGServer::ATTRTYPE_BOOL, VGServer::AnyType::convertType(), VGServer::AnyType::getInteger(), VGServer::AnyType::getValueLength(), VGServer::GraphData::properties, VGServer::TpAttributeBlob< AllocPolicy >::putAnyType(), VGServer::TpAttributeBlob< AllocPolicy >::putBool(), VGServer::GraphData::vertexattr, and VGServer::GraphProperties::vertexattr.
Referenced by VGServer::GraphLoaderKFile::load().
void VGServer::GraphLoader::terminate | ( | ) |
add the termination nodes, this will be called automaticly by finish().
Definition at line 44 of file GraphLoader.cc.
References VGServer::GraphData::Edge::attridx, VGServer::GraphData::Vertex::attridx, VGServer::GraphData::edges, VGServer::VERTEX_INVALID, and VGServer::GraphData::vertices.
Referenced by finish().