dyng
DynamicGraphLayout
Public Types | Public Member Functions | List of all members
dyng::graph< NodeType, EdgeType > Class Template Reference

Templated class for representing a static graph and its layout. More...

#include <graph.h>

Public Types

using node_edges = std::unordered_map< node_id, edge_id >
 Typedef to simplify return type of the method edges_at_node().
 

Public Member Functions

 graph (const graph< NodeType, EdgeType > &other)
 
graph< NodeType, EdgeType > & operator= (const graph< NodeType, EdgeType > &other)
 
 graph (graph< NodeType, EdgeType > &&other)
 
graph< NodeType, EdgeType > & operator= (graph< NodeType, EdgeType > &&other)
 
const std::vector< NodeType > & nodes () const
 Returns const reference to the vector of all nodes in the graph.
 
std::vector< NodeType > & nodes ()
 Returns reference to the vector of all nodes in the graph. More...
 
const std::vector< EdgeType > & edges () const
 Returns const reference to the vector of all edges in the graph.
 
std::vector< EdgeType > & edges ()
 Returns reference to the vector of all edges in the graph. More...
 
const NodeType & node_at (node_id id) const
 Returns reference to node of given id. More...
 
NodeType & node_at (node_id id)
 Returns reference to node of given id. More...
 
const EdgeType & edge_at (edge_id id) const
 Returns reference to edge of given id. More...
 
EdgeType & edge_at (edge_id id)
 Returns reference to edge of given id. More...
 
unsigned node_index (node_id id) const
 Returns the index of a node corresponding to its position in nodes(). More...
 
unsigned edge_index (edge_id id) const
 Returns the index of an edge corresponding to its position in edges(). More...
 
template<typename Function >
void remove_edges_if (Function function)
 
template<typename Function >
void remove_nodes_if (Function function)
 
void remove_edge (edge_id id)
 Removes a single edge. More...
 
void remove_node (node_id id)
 Removes a single node. More...
 
NodeType & push_node (NodeType node)
 Adds a new node to the graph.
 
template<typename ... Args>
NodeType & emplace_node (Args &&... args)
 Constructs a new node and adds it to the graph.
 
EdgeType & push_edge (EdgeType edge)
 Adds a new edge to the graph.
 
template<typename ... Args>
EdgeType & emplace_edge (Args &&... args)
 Constructs a new edge and adds it to the graph.
 
void clear_edges ()
 Removes all edges.
 
void clear_nodes ()
 Removes all nodes.
 
bool node_exists (node_id id) const
 Returns whether a node of a given id exists.
 
bool edge_exists (edge_id id) const
 Returns whether an edge of a given id exists. More...
 
bool edge_exists (node_id one, node_id two) const
 
const node_edgesedges_at_node (node_id node) const
 Returns a container containing all edges adjacent to a given node. More...
 

Detailed Description

template<typename NodeType, typename EdgeType>
class dyng::graph< NodeType, EdgeType >

Templated class for representing a static graph and its layout.

(Described in section 6.1.4 – as the alias 'graph_state')

Template Parameters
NodeTypeType of the node.
EdgeTypeType of the edge.
See also
graph_state, dynamic_graph

Member Function Documentation

◆ edge_at() [1/2]

template<typename NodeType , typename EdgeType >
EdgeType& dyng::graph< NodeType, EdgeType >::edge_at ( edge_id  id)
inline

Returns reference to edge of given id.

Exceptions
std::out_of_rangeIf edge of id doesn't exist.

◆ edge_at() [2/2]

template<typename NodeType , typename EdgeType >
const EdgeType& dyng::graph< NodeType, EdgeType >::edge_at ( edge_id  id) const
inline

Returns reference to edge of given id.

Exceptions
std::out_of_rangeIf edge of id doesn't exist.

◆ edge_exists() [1/2]

template<typename NodeType , typename EdgeType >
bool dyng::graph< NodeType, EdgeType >::edge_exists ( edge_id  id) const
inline

Returns whether an edge of a given id exists.

See also
edge_exists(node_id, node_id)

◆ edge_exists() [2/2]

template<typename NodeType , typename EdgeType >
bool dyng::graph< NodeType, EdgeType >::edge_exists ( node_id  one,
node_id  two 
) const
inline

Returns whether or not there is an edge between two nodes identified by node_id one and two.

Note: edge_exists(a, b) is equivalent to edge_exists(b, a).

Exceptions
std::out_of_rangeIf either one or two doesn't exist.

◆ edge_index()

template<typename NodeType , typename EdgeType >
unsigned dyng::graph< NodeType, EdgeType >::edge_index ( edge_id  id) const
inline

Returns the index of an edge corresponding to its position in edges().

Exceptions
std::out_of_rangeIf edge of id doesn't exist.

◆ edges()

template<typename NodeType , typename EdgeType >
std::vector<EdgeType>& dyng::graph< NodeType, EdgeType >::edges ( )
inline

Returns reference to the vector of all edges in the graph.

You should not add/remove any elements to/from the vector (use coresponding graph methods instead).

See also
push_edge, emplace_edge, remove_edge, remove_edges_if, clear_edges

◆ edges_at_node()

template<typename NodeType , typename EdgeType >
const node_edges& dyng::graph< NodeType, EdgeType >::edges_at_node ( node_id  node) const
inline

Returns a container containing all edges adjacent to a given node.

The container node_edges is a map of node ids to edge ids.

Exceptions
std::out_of_rangeIf one doesn't exist.
See also
graph::node_edges

◆ node_at() [1/2]

template<typename NodeType , typename EdgeType >
NodeType& dyng::graph< NodeType, EdgeType >::node_at ( node_id  id)
inline

Returns reference to node of given id.

Exceptions
std::out_of_rangeIf node of id doesn't exist.

◆ node_at() [2/2]

template<typename NodeType , typename EdgeType >
const NodeType& dyng::graph< NodeType, EdgeType >::node_at ( node_id  id) const
inline

Returns reference to node of given id.

Exceptions
std::out_of_rangeIf node of id doesn't exist.

◆ node_index()

template<typename NodeType , typename EdgeType >
unsigned dyng::graph< NodeType, EdgeType >::node_index ( node_id  id) const
inline

Returns the index of a node corresponding to its position in nodes().

Exceptions
std::out_of_rangeIf node of id doesn't exist.

◆ nodes()

template<typename NodeType , typename EdgeType >
std::vector<NodeType>& dyng::graph< NodeType, EdgeType >::nodes ( )
inline

Returns reference to the vector of all nodes in the graph.

You should not add/remove any elements to/from the vector (use coresponding methods instead).

See also
push_node, emplace_node, remove_node, remove_nodes_if, clear_nodes

◆ remove_edge()

template<typename NodeType , typename EdgeType >
void dyng::graph< NodeType, EdgeType >::remove_edge ( edge_id  id)
inline

Removes a single edge.

Has the same complexity as remove_edges_if().

Exceptions
invalid_graphIf the edge does not exist.

◆ remove_edges_if()

template<typename NodeType , typename EdgeType >
template<typename Function >
void dyng::graph< NodeType, EdgeType >::remove_edges_if ( Function  function)
inline

Removes all edges for which parameter function returns true. This methods needs to make sure all internal structures remain consistent which makes it very inefficient.

Parameters
functionExpected signature: 'bool(const EdgeType&)'.

◆ remove_node()

template<typename NodeType , typename EdgeType >
void dyng::graph< NodeType, EdgeType >::remove_node ( node_id  id)
inline

Removes a single node.

Has the same complexity as remove_nodes_if().

Exceptions
invalid_graphIf the node does not exist.

◆ remove_nodes_if()

template<typename NodeType , typename EdgeType >
template<typename Function >
void dyng::graph< NodeType, EdgeType >::remove_nodes_if ( Function  function)
inline

Removes all nodes for which parameter function returns true. This methods needs to make sure all internal structures remain consistent which makes it very inefficient.

Parameters
functionExpected signature: 'bool(const NodeType&)'.

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