libgexf  0.1.3
Public Member Functions | Protected Attributes | Friends | List of all members
libgexf::Graph Class Reference

Topology structure of the graph. More...

#include <graph.h>

Inheritance diagram for libgexf::Graph:
libgexf::DirectedGraph libgexf::UndirectedGraph

Public Member Functions

 Graph (const Graph &orig)
 Copy constructor.
 
void addNode (const libgexf::t_id id)
 Add a node. More...
 
void addEdge (const libgexf::t_id id, const libgexf::t_id source_id, const libgexf::t_id target_id, const float weight=1.0, const libgexf::t_edge_type type=EDGE_UNDEF)
 Add an edge. More...
 
void removeNode (const libgexf::t_id id)
 Remove a node. More...
 
void removeEdge (const libgexf::t_id source_id, const libgexf::t_id target_id)
 Remove an edge. More...
 
bool containsNode (const libgexf::t_id id) const
 Test node existence. More...
 
bool containsEdge (const libgexf::t_id source_id, const libgexf::t_id target_id) const
 Test edge existence. More...
 
t_id getEdge (const libgexf::t_id source_id, const libgexf::t_id target_id) const
 Get the edge id. More...
 
libgexf::NodeItergetNodes () const
 Get all nodes. More...
 
libgexf::EdgeItergetEdges () const
 Get all edges. More...
 
std::vector< libgexf::t_idgetNeighbors (const libgexf::t_id node_id) const
 Get node neighbors. More...
 
unsigned int getNodeCount () const
 Count the nodes. More...
 
unsigned int getEdgeCount () const
 Count the edges. More...
 
unsigned int getDegree (const libgexf::t_id node_id) const
 Get node degree. More...
 
void clearEdges (const libgexf::t_id node_id)
 Delete node links. More...
 
void clear ()
 Clear the graph.
 
void clearEdges ()
 Delete all edges.
 
void readLock () throw (libgexf::ReadLockException)
 Set a lock on reading. More...
 
void readUnlock ()
 Unset a lock on reading.
 
void writeLock () throw (libgexf::WriteLockException)
 Get a lock on writing. More...
 
void writeUnlock ()
 Unset a lock on writing.
 
bool isReadLock ()
 Test if a read lock exists.
 
bool isWriteLock ()
 Test if a write lock exists.
 
bool isUnlock ()
 Unset all locks.
 

Protected Attributes

std::set< t_id_nodes
 
std::map< t_id, std::map< t_id, t_id > > _edges
 
std::map< t_id, std::set< t_id > > _reverse_edges
 
std::set< t_id_bloom_edges
 
std::map< t_id, std::map< t_edge_property, t_edge_value > > _edges_properties
 
unsigned short int _rlock_count
 
char _lock_flag
 Flag used for determining the lock type: More...
 

Friends

class NodeIter
 
class EdgeIter
 
std::ostream & operator<< (std::ostream &os, const Graph &o)
 

Detailed Description

Topology structure of the graph.

Member Function Documentation

◆ addEdge()

void libgexf::Graph::addEdge ( const libgexf::t_id  id,
const libgexf::t_id  source_id,
const libgexf::t_id  target_id,
const float  weight = 1.0,
const libgexf::t_edge_type  type = EDGE_UNDEF 
)

Add an edge.

Parameters
id: edge ID
source_id: source node ID
target_id: target node ID
weight: weight of the edge (optional, 1.0 by default)
type: type of edge (optional, undef by default)

◆ addNode()

void libgexf::Graph::addNode ( const libgexf::t_id  id)

Add a node.

Parameters
id: node ID

◆ clearEdges()

void libgexf::Graph::clearEdges ( const libgexf::t_id  node_id)

Delete node links.

Parameters
node_id: node ID

◆ containsEdge()

bool libgexf::Graph::containsEdge ( const libgexf::t_id  source_id,
const libgexf::t_id  target_id 
) const

Test edge existence.

Parameters
source_id: source node ID
target_id: target node ID
Returns
true if the edge exists, false otherwise

◆ containsNode()

bool libgexf::Graph::containsNode ( const libgexf::t_id  id) const

Test node existence.

Parameters
id: node ID
Returns
true if the node exists, false otherwise

◆ getDegree()

unsigned int libgexf::Graph::getDegree ( const libgexf::t_id  node_id) const

Get node degree.

Parameters
node_id: node ID
Returns
Degree

◆ getEdge()

t_id libgexf::Graph::getEdge ( const libgexf::t_id  source_id,
const libgexf::t_id  target_id 
) const

Get the edge id.

Parameters
source_id: source node ID
target_id: target node ID
Returns
the edge id the edge exists, empty string otherwise

◆ getEdgeCount()

unsigned int libgexf::Graph::getEdgeCount ( ) const

Count the edges.

Returns
Number of edges

◆ getEdges()

EdgeIter * libgexf::Graph::getEdges ( ) const

Get all edges.

Returns
Iterator on the edge collection

◆ getNeighbors()

vector< t_id > libgexf::Graph::getNeighbors ( const libgexf::t_id  node_id) const

Get node neighbors.

Parameters
node_id: node ID
Returns
Vector of nodes directly linked to the node

◆ getNodeCount()

unsigned int libgexf::Graph::getNodeCount ( ) const

Count the nodes.

Returns
Number of nodes

◆ getNodes()

NodeIter * libgexf::Graph::getNodes ( ) const

Get all nodes.

Returns
Iterator on the node collection

◆ readLock()

void libgexf::Graph::readLock ( )
throw (libgexf::ReadLockException
)

Set a lock on reading.

Exceptions
ReadLockException{ Unable to set the lock }

◆ removeEdge()

void libgexf::Graph::removeEdge ( const libgexf::t_id  source_id,
const libgexf::t_id  target_id 
)

Remove an edge.

Parameters
source_id: source node ID
target_id: target node ID

◆ removeNode()

void libgexf::Graph::removeNode ( const libgexf::t_id  id)

Remove a node.

Parameters
id: node ID

◆ writeLock()

void libgexf::Graph::writeLock ( )
throw (libgexf::WriteLockException
)

Get a lock on writing.

Exceptions
WriteLockException{ Unable to set the lock }

Member Data Documentation

◆ _bloom_edges

std::set<t_id> libgexf::Graph::_bloom_edges
protected

Set of all edge_id used as a (poor) bloom filter

◆ _edges

std::map<t_id,std::map<t_id,t_id> > libgexf::Graph::_edges
protected

map<source_id, map<target_id, edge_id> >

◆ _edges_properties

std::map<t_id,std::map<t_edge_property,t_edge_value> > libgexf::Graph::_edges_properties
protected

Topological properties of edges

◆ _lock_flag

char libgexf::Graph::_lock_flag
protected

Flag used for determining the lock type:

  • 0 = unlocked
  • 1 = read locked
  • 2 = write locked

◆ _nodes

std::set<t_id> libgexf::Graph::_nodes
protected

Set of all nodes

◆ _reverse_edges

std::map<t_id,std::set<t_id> > libgexf::Graph::_reverse_edges
protected

map<target_id, set<source_id> >

◆ _rlock_count

unsigned short int libgexf::Graph::_rlock_count
protected

Number of read-locks


The documentation for this class was generated from the following files: