#include <GraphData.h>
Inheritance diagram for VGServer::GraphData:
Public Member Functions | |
void | applyChangelist (const class Changelist &cl) |
this takes the changes from cl and merges them into the current graph data. | |
bool | checkReferences () const |
checks all adjacency array references | |
bool | existEdge (vertexid_t src, vertexid_t tgt) const |
checks if an edge exists | |
bool | existVertex (vertexid_t id) const |
checks if the vertex id exists, that is if it has any attribute data | |
const Edge * | getEdge (vertexid_t src, vertexid_t tgt) const |
return a single edge object (if it exists) | |
AnyType | getEdgeAttr (vertexid_t src, vertexid_t tgt, unsigned int attr) const |
returns the value of an edge attribute by (src,tgt) vertex ids | |
AttributeEdgeTinyBlob | getEdgeAttrBlob (vertexid_t src, vertexid_t tgt) const |
returns a copy of the attribute values of an edge as a TinyBlob. | |
unsigned int | getEdgeAttrBytes () const |
returns number of used bytes in the edge attribute array | |
unsigned int | getEdgeCount () const |
returns the number of valid edges | |
unsigned int | getEdgeIdx (vertexid_t src, vertexid_t tgt) const |
returns the index of a valid edge into the edges array | |
std::vector< unsigned int > | getEdgeIdxList (vertexid_t id) const |
return the list of outgoing edge indices | |
std::vector< const Edge * > | getEdgeList (vertexid_t id) const |
return the list of outgoing edges | |
std::vector< unsigned int > | getEdgeTargetList (vertexid_t srcid) const |
return a list of destination indices of the outgoing edges of srcid | |
const GraphProperties & | getProperties () const |
returns the currently used GraphProperties object | |
const Vertex * | getVertex (vertexid_t id) const |
return a single vertex object | |
AnyType | getVertexAttr (vertexid_t id, unsigned int attr) const |
returns the value of a vertex attribute by id | |
AttributeVertexTinyBlob | getVertexAttrBlob (vertexid_t id) const |
returns a copy of the attribute values of a vertex as a TinyBlob. | |
unsigned int | getVertexAttrBytes () const |
returns number of used bytes in the vertex attribute array | |
unsigned int | getVertexCount () const |
returns the number of non-blank vertices | |
GraphData (const class GraphProperties &properties) | |
bool | loadSnapshot (std::istream &s) |
reload the global static graph arrays from a snapshot | |
void | saveSnapshot (std::ostream &s) const |
write the global static graph arrays as a snapshot which can be loaded very fast. | |
void | swap (class GraphData &other) |
this will swap the data holder objects with the other GraphData object. | |
void | writeFig (bool writefigheader, std::ostream &s, unsigned int attrX, unsigned int attrY) const |
write the whole graph as a fig file. this can get very big | |
Public Attributes | |
AttributeBigBlob | edgeattr |
byte blob containing all edge attributes packed | |
TpArray< Edge > | edges |
STL vector containing the adjacency array. | |
GraphProperties | properties |
initialized by the constructor | |
AttributeBigBlob | vertexattr |
byte blob containing all vertex attributes packed using default bitfields and fixed lengths specified in the GraphProperties. | |
unsigned int | vertexcount |
cached number of valid (non-blank) vertices, this is not vertices.size() because the vertex array may contain blank objects which are viewed as non-existing. | |
TpArray< Vertex > | vertices |
STL vector is used with caution: it should never auto-grow. | |
Friends | |
class | Changelist |
accesses protected functions through GraphContainer | |
class | EdgeRef |
direct access into the edge array | |
class | GraphContainer |
accesses vertices and edges directly read-only | |
class | GraphLoader |
directly writes the data into the arrays | |
class | VertexRef |
direct access into the vertex array | |
Classes | |
struct | Edge |
allocated millions of times in the adjacency array More... | |
struct | Vertex |
allocated millions of times in the vertex array More... |
It is represented by the vertex and it's adjacency arrays. This data could also be put into GraphContainer directly, but by separating it, a new graph can be prepared (e.g. loaded from file by GraphLoader) and activated while the server is still handling requests.
Definition at line 22 of file GraphData.h.
VGServer::GraphData::GraphData | ( | const class GraphProperties & | properties | ) | [explicit] |
Definition at line 15 of file GraphData.cc.
References VGServer::GraphData::Vertex::attridx, VGServer::GraphProperties::calcAttributeLookups(), VGServer::GraphData::Vertex::edgeidx, edges, properties, vertexcount, and vertices.
void VGServer::GraphData::applyChangelist | ( | const class Changelist & | cl | ) |
this takes the changes from cl and merges them into the current graph data.
this operation takes a long time, because the arrays are reconstructed. care should be taken not to access the data in this time.
Reimplemented in VGServer::GraphContainer.
Definition at line 45 of file GraphData.cc.
References VGServer::GraphData::Edge::attridx, checkReferences(), VGServer::TpAttributeBlob< AllocPolicy >::copy(), VGServer::TpAttributeBlob< AllocPolicy >::data(), VGServer::GraphProperties::edgeattr, edgeattr, edges, VGServer::TpAttributeBlob< AllocPolicy >::getAttrChainLength(), VGServer::TpArray< Tp >::new_back(), properties, VGServer::TpArray< Tp >::reserve(), VGServer::TpArray< Tp >::size(), VGServer::TpAttributeBlob< AllocPolicy >::swap(), VGServer::GraphData::Edge::target, VGServer::VERTEX_INVALID, vertexattr, VGServer::GraphProperties::vertexattr, vertexcount, and vertices.
Referenced by VGServer::GraphContainer::applyChangelist().
bool VGServer::GraphData::checkReferences | ( | ) | const |
checks all adjacency array references
Definition at line 380 of file GraphData.cc.
References edgeattr, edges, funcassert, VGServer::TpAttributeBlob< AllocPolicy >::size(), vertexattr, and vertices.
Referenced by applyChangelist().
bool VGServer::GraphData::existEdge | ( | vertexid_t | src, | |
vertexid_t | tgt | |||
) | const |
checks if an edge exists
Definition at line 478 of file GraphData.cc.
References edges, and getEdgeIdx().
Referenced by VGServer::Changelist::addEdge(), VGServer::Changelist::delEdge(), and VGServer::Changelist::setEdgeAttr().
bool VGServer::GraphData::existVertex | ( | vertexid_t | id | ) | const |
checks if the vertex id exists, that is if it has any attribute data
Definition at line 421 of file GraphData.cc.
References vertices.
Referenced by VGServer::Changelist::addVertex(), VGServer::Changelist::delVertex(), VGServer::GraphContainer::getVertex(), VGServer::Changelist::setVertexAttr(), and writeFig().
const GraphData::Edge * VGServer::GraphData::getEdge | ( | vertexid_t | src, | |
vertexid_t | tgt | |||
) | const |
class AnyType VGServer::GraphData::getEdgeAttr | ( | vertexid_t | src, | |
vertexid_t | tgt, | |||
unsigned int | attr | |||
) | const |
returns the value of an edge attribute by (src,tgt) vertex ids
Definition at line 483 of file GraphData.cc.
References VGServer::AnyType::AnyType(), and VGServer::ATTRTYPE_INVALID.
Referenced by VGServer::GraphContainer::applyChangelist().
AttributeEdgeTinyBlob VGServer::GraphData::getEdgeAttrBlob | ( | vertexid_t | src, | |
vertexid_t | tgt | |||
) | const |
returns a copy of the attribute values of an edge as a TinyBlob.
Definition at line 490 of file GraphData.cc.
References VGServer::TpAttributeBlob< AllocPolicy >::data(), edgeattr, edges, and vertices.
Referenced by VGServer::Changelist::addEdge(), and VGServer::Changelist::setEdgeAttr().
unsigned int VGServer::GraphData::getEdgeAttrBytes | ( | ) | const [inline] |
returns number of used bytes in the edge attribute array
Definition at line 168 of file GraphData.h.
References edges.
unsigned int VGServer::GraphData::getEdgeCount | ( | ) | const [inline] |
returns the number of valid edges
Definition at line 160 of file GraphData.h.
References edges.
Referenced by VGServer::GraphContainer::applyChangelist().
unsigned int VGServer::GraphData::getEdgeIdx | ( | vertexid_t | src, | |
vertexid_t | tgt | |||
) | const |
returns the index of a valid edge into the edges array
Definition at line 443 of file GraphData.cc.
References edges, and vertices.
Referenced by existEdge(), and VGServer::GraphContainer::getEdge().
std::vector< unsigned int > VGServer::GraphData::getEdgeIdxList | ( | vertexid_t | id | ) | const |
return the list of outgoing edge indices
Definition at line 526 of file GraphData.cc.
References vertices.
std::vector< const GraphData::Edge * > VGServer::GraphData::getEdgeList | ( | vertexid_t | id | ) | const |
std::vector< unsigned int > VGServer::GraphData::getEdgeTargetList | ( | vertexid_t | srcid | ) | const |
return a list of destination indices of the outgoing edges of srcid
Definition at line 541 of file GraphData.cc.
const GraphProperties& VGServer::GraphData::getProperties | ( | ) | const [inline] |
returns the currently used GraphProperties object
Definition at line 112 of file GraphData.h.
References properties.
Referenced by VGServer::EdgeRef::getAttr(), and VGServer::VertexRef::getAttr().
const GraphData::Vertex * VGServer::GraphData::getVertex | ( | vertexid_t | id | ) | const |
class AnyType VGServer::GraphData::getVertexAttr | ( | vertexid_t | id, | |
unsigned int | attr | |||
) | const |
returns the value of a vertex attribute by id
Definition at line 428 of file GraphData.cc.
Referenced by VGServer::GraphContainer::RTreeDataCallback::getMBR(), and writeFig().
AttributeVertexTinyBlob VGServer::GraphData::getVertexAttrBlob | ( | vertexid_t | id | ) | const |
returns a copy of the attribute values of a vertex as a TinyBlob.
Definition at line 434 of file GraphData.cc.
References VGServer::TpAttributeBlob< AllocPolicy >::data(), vertexattr, and vertices.
Referenced by VGServer::Changelist::addVertex(), and VGServer::Changelist::setVertexAttr().
unsigned int VGServer::GraphData::getVertexAttrBytes | ( | ) | const [inline] |
returns number of used bytes in the vertex attribute array
Definition at line 164 of file GraphData.h.
References vertices.
unsigned int VGServer::GraphData::getVertexCount | ( | ) | const [inline] |
returns the number of non-blank vertices
Definition at line 130 of file GraphData.h.
References vertexcount.
bool VGServer::GraphData::loadSnapshot | ( | std::istream & | s | ) |
reload the global static graph arrays from a snapshot
Reimplemented in VGServer::GraphContainer.
Definition at line 618 of file GraphData.cc.
References VGServer::TpAttributeBlob< AllocPolicy >::alloc(), VGServer::GraphProperties::appendBinaryFormat(), VGServer::TpAttributeBlob< AllocPolicy >::data(), VGServer::ByteBuffer::data(), edgeattr, edges, properties, VGServer::ByteBuffer::size(), vertexattr, vertexcount, and vertices.
Referenced by VGServer::GraphContainer::loadSnapshot().
void VGServer::GraphData::saveSnapshot | ( | std::ostream & | s | ) | const |
write the global static graph arrays as a snapshot which can be loaded very fast.
Reimplemented in VGServer::GraphContainer.
Definition at line 556 of file GraphData.cc.
References VGServer::GraphProperties::appendBinaryFormat(), VGServer::TpAttributeBlob< AllocPolicy >::data(), VGServer::ByteBuffer::data(), edgeattr, edges, properties, VGServer::ByteBuffer::size(), vertexattr, and vertices.
Referenced by VGServer::GraphContainer::saveSnapshot().
void VGServer::GraphData::swap | ( | class GraphData & | other | ) |
this will swap the data holder objects with the other GraphData object.
Definition at line 30 of file GraphData.cc.
References edgeattr, edges, properties, VGServer::TpAttributeBlob< AllocPolicy >::swap(), vertexattr, vertexcount, and vertices.
Referenced by VGServer::GraphContainer::applyGraphData(), and VGServer::GraphContainer::swap().
void VGServer::GraphData::writeFig | ( | bool | writefigheader, | |
std::ostream & | s, | |||
unsigned int | attrX, | |||
unsigned int | attrY | |||
) | const |
write the whole graph as a fig file. this can get very big
Definition at line 349 of file GraphData.cc.
References edges, existVertex(), VGServer::AnyType::getString(), getVertexAttr(), VGServer::VERTEX_INVALID, and vertices.
friend class Changelist [friend] |
friend class EdgeRef [friend] |
direct access into the edge array
Definition at line 94 of file GraphData.h.
Referenced by VGServer::GraphContainer::getEdge(), and VGServer::GraphContainer::getEdgeList().
friend class GraphContainer [friend] |
friend class GraphLoader [friend] |
friend class VertexRef [friend] |
direct access into the vertex array
Definition at line 91 of file GraphData.h.
Referenced by VGServer::GraphContainer::getVertex().
byte blob containing all edge attributes packed
Definition at line 74 of file GraphData.h.
Referenced by VGServer::GraphLoader::addEdge(), applyChangelist(), checkReferences(), getEdgeAttrBlob(), loadSnapshot(), VGServer::GraphLoader::reserve(), saveSnapshot(), VGServer::GraphLoader::setEdgeAttr(), and swap().
STL vector containing the adjacency array.
Definition at line 67 of file GraphData.h.
Referenced by VGServer::GraphLoader::addEdge(), applyChangelist(), checkReferences(), existEdge(), VGServer::EdgeRef::getAttr(), getEdge(), VGServer::GraphContainer::getEdge(), getEdgeAttrBlob(), getEdgeAttrBytes(), getEdgeCount(), getEdgeIdx(), getEdgeList(), VGServer::GraphContainer::getEdgeList(), getEdgeTargetList(), VGServer::EdgeRef::getTarget(), GraphData(), VGServer::GraphLoader::GraphLoader(), loadSnapshot(), VGServer::GraphLoader::reserve(), saveSnapshot(), swap(), VGServer::GraphLoader::terminate(), and writeFig().
initialized by the constructor
Definition at line 61 of file GraphData.h.
Referenced by VGServer::GraphLoader::addEdge(), VGServer::Changelist::addEdge(), VGServer::GraphLoader::addVertex(), VGServer::Changelist::addVertex(), applyChangelist(), VGServer::GraphContainer::getArea(), VGServer::GraphContainer::getGraphProperties(), VGServer::GraphContainer::getNearestNeighbor(), getProperties(), GraphData(), loadSnapshot(), saveSnapshot(), VGServer::GraphLoader::setEdgeAttr(), VGServer::Changelist::setEdgeAttr(), VGServer::GraphLoader::setVertexAttr(), VGServer::Changelist::setVertexAttr(), and swap().
byte blob containing all vertex attributes packed using default bitfields and fixed lengths specified in the GraphProperties.
Definition at line 71 of file GraphData.h.
Referenced by VGServer::GraphLoader::addVertex(), applyChangelist(), checkReferences(), getVertexAttrBlob(), loadSnapshot(), VGServer::GraphLoader::reserve(), saveSnapshot(), VGServer::GraphLoader::setVertexAttr(), and swap().
unsigned int VGServer::GraphData::vertexcount |
cached number of valid (non-blank) vertices, this is not vertices.size() because the vertex array may contain blank objects which are viewed as non-existing.
Definition at line 79 of file GraphData.h.
Referenced by VGServer::GraphLoader::addVertex(), applyChangelist(), VGServer::GraphContainer::getArea(), getVertexCount(), GraphData(), loadSnapshot(), and swap().
STL vector is used with caution: it should never auto-grow.
Definition at line 64 of file GraphData.h.
Referenced by VGServer::GraphLoader::addEdge(), VGServer::GraphLoader::addVertex(), applyChangelist(), checkReferences(), existVertex(), VGServer::VertexRef::getAttr(), getEdge(), getEdgeAttrBlob(), getEdgeIdx(), getEdgeIdxList(), getEdgeList(), VGServer::GraphContainer::getEdgeList(), getEdgeTargetList(), getVertex(), getVertexAttrBlob(), getVertexAttrBytes(), GraphData(), VGServer::GraphLoader::GraphLoader(), loadSnapshot(), VGServer::GraphLoader::reserve(), saveSnapshot(), swap(), VGServer::GraphLoader::terminate(), and writeFig().