Graph< NodePropertyT, EdgePropertyT > Class Template Reference

CPP API: mio::Graph< NodePropertyT, EdgePropertyT > Class Template Reference
mio::Graph< NodePropertyT, EdgePropertyT > Class Template Reference

generic graph structure More...

#include <graph.h>

Inheritance diagram for mio::Graph< NodePropertyT, EdgePropertyT >:
Collaboration diagram for mio::Graph< NodePropertyT, EdgePropertyT >:

Public Types

using EdgeProperty = EdgePropertyT
 
using NodeProperty = NodePropertyT
 

Public Member Functions

template<class... Args>
requires std::constructible_from< EdgePropertyT, Args... > void add_edge (size_t start_node_idx, size_t end_node_idx, Args &&... args)
 add an edge to the graph. More...
 
template<class... Args>
requires std::constructible_from< NodePropertyT, Args... > void add_node (int id, Args &&... args)
 add a node to the graph. More...
 
auto edges ()
 range of edges More...
 
auto edges () const
 range of edges More...
 
 Graph ()=default
 
template<class... Args>
requires std::constructible_from< NodePropertyT, Args... > Graph (const int number_of_nodes, Args &&... args)
 Construct graph without edges, creating each node from the same node_args with default node ids [0, 1, ...]. More...
 
template<class... Args>
requires std::constructible_from< NodePropertyT, Args... > Graph (const std::vector< int > &node_ids, Args &&... node_args)
 Construct graph without edges, creating a node for each id in node_ids from the same node_args. More...
 
 Graph (const std::vector< int > &node_ids, const std::vector< NodePropertyT > &node_properties)
 Construct graph without edges from pairs of node_ids and node_properties. More...
 
 Graph (std::vector< Node< NodePropertyT >> &&nodes, std::vector< Edge< EdgePropertyT >> &&edges)
 Construct graph containing the given nodes and edges. More...
 
 Graph (std::vector< NodePropertyT > &node_properties)
 Construct graph without edges from node_properties with default node ids [0, 1, ...]. More...
 
auto nodes ()
 range of nodes More...
 
auto nodes () const
 range of nodes More...
 
auto out_edges (size_t node_idx)
 range of edges going out from a specific node More...
 
auto out_edges (size_t node_idx) const
 range of edges going out from a specific node More...
 

Static Private Member Functions

template<typename Iter >
static auto out_edges (Iter b, Iter e, size_t idx)
 

Private Attributes

std::vector< Edge< EdgePropertyT > > m_edges
 
std::vector< Node< NodePropertyT > > m_nodes
 

Detailed Description

template<class NodePropertyT, class EdgePropertyT>
class mio::Graph< NodePropertyT, EdgePropertyT >

generic graph structure

Member Typedef Documentation

◆ EdgeProperty

template<class NodePropertyT , class EdgePropertyT >
using mio::Graph< NodePropertyT, EdgePropertyT >::EdgeProperty = EdgePropertyT

◆ NodeProperty

template<class NodePropertyT , class EdgePropertyT >
using mio::Graph< NodePropertyT, EdgePropertyT >::NodeProperty = NodePropertyT

Constructor & Destructor Documentation

◆ Graph() [1/6]

template<class NodePropertyT , class EdgePropertyT >
mio::Graph< NodePropertyT, EdgePropertyT >::Graph ( const std::vector< int > &  node_ids,
const std::vector< NodePropertyT > &  node_properties 
)
inline

Construct graph without edges from pairs of node_ids and node_properties.

◆ Graph() [2/6]

template<class NodePropertyT , class EdgePropertyT >
mio::Graph< NodePropertyT, EdgePropertyT >::Graph ( std::vector< NodePropertyT > &  node_properties)
inline

Construct graph without edges from node_properties with default node ids [0, 1, ...].

◆ Graph() [3/6]

template<class NodePropertyT , class EdgePropertyT >
template<class... Args>
requires std::constructible_from<NodePropertyT, Args...> mio::Graph< NodePropertyT, EdgePropertyT >::Graph ( const std::vector< int > &  node_ids,
Args &&...  node_args 
)
inline

Construct graph without edges, creating a node for each id in node_ids from the same node_args.

◆ Graph() [4/6]

template<class NodePropertyT , class EdgePropertyT >
template<class... Args>
requires std::constructible_from<NodePropertyT, Args...> mio::Graph< NodePropertyT, EdgePropertyT >::Graph ( const int  number_of_nodes,
Args &&...  args 
)
inline

Construct graph without edges, creating each node from the same node_args with default node ids [0, 1, ...].

◆ Graph() [5/6]

template<class NodePropertyT , class EdgePropertyT >
mio::Graph< NodePropertyT, EdgePropertyT >::Graph ( )
default

◆ Graph() [6/6]

template<class NodePropertyT , class EdgePropertyT >
mio::Graph< NodePropertyT, EdgePropertyT >::Graph ( std::vector< Node< NodePropertyT >> &&  nodes,
std::vector< Edge< EdgePropertyT >> &&  edges 
)
inline

Construct graph containing the given nodes and edges.

Member Function Documentation

◆ add_edge()

template<class NodePropertyT , class EdgePropertyT >
template<class... Args>
requires std::constructible_from<EdgePropertyT, Args...> void mio::Graph< NodePropertyT, EdgePropertyT >::add_edge ( size_t  start_node_idx,
size_t  end_node_idx,
Args &&...  args 
)
inline

add an edge to the graph.

The property of the edge is constructed from arguments.

Parameters
start_node_idxid of start node
end_node_idxid of end node
Template Parameters
argsadditional arguments for edge construction

If an edge with the same start and end node indices already exists, it is replaced by the newly constructed edge.

◆ add_node()

template<class NodePropertyT , class EdgePropertyT >
template<class... Args>
requires std::constructible_from<NodePropertyT, Args...> void mio::Graph< NodePropertyT, EdgePropertyT >::add_node ( int  id,
Args &&...  args 
)
inline

add a node to the graph.

The property of the node is constructed from arguments.

Parameters
idid for the node
Template Parameters
argsadditional arguments for node construction

◆ edges() [1/2]

template<class NodePropertyT , class EdgePropertyT >
auto mio::Graph< NodePropertyT, EdgePropertyT >::edges ( )
inline

range of edges

◆ edges() [2/2]

template<class NodePropertyT , class EdgePropertyT >
auto mio::Graph< NodePropertyT, EdgePropertyT >::edges ( ) const
inline

range of edges

◆ nodes() [1/2]

template<class NodePropertyT , class EdgePropertyT >
auto mio::Graph< NodePropertyT, EdgePropertyT >::nodes ( )
inline

range of nodes

◆ nodes() [2/2]

template<class NodePropertyT , class EdgePropertyT >
auto mio::Graph< NodePropertyT, EdgePropertyT >::nodes ( ) const
inline

range of nodes

◆ out_edges() [1/3]

template<class NodePropertyT , class EdgePropertyT >
template<typename Iter >
static auto mio::Graph< NodePropertyT, EdgePropertyT >::out_edges ( Iter  b,
Iter  e,
size_t  idx 
)
inlinestaticprivate

◆ out_edges() [2/3]

template<class NodePropertyT , class EdgePropertyT >
auto mio::Graph< NodePropertyT, EdgePropertyT >::out_edges ( size_t  node_idx)
inline

range of edges going out from a specific node

◆ out_edges() [3/3]

template<class NodePropertyT , class EdgePropertyT >
auto mio::Graph< NodePropertyT, EdgePropertyT >::out_edges ( size_t  node_idx) const
inline

range of edges going out from a specific node

Member Data Documentation

◆ m_edges

template<class NodePropertyT , class EdgePropertyT >
std::vector<Edge<EdgePropertyT> > mio::Graph< NodePropertyT, EdgePropertyT >::m_edges
private

◆ m_nodes

template<class NodePropertyT , class EdgePropertyT >
std::vector<Node<NodePropertyT> > mio::Graph< NodePropertyT, EdgePropertyT >::m_nodes
private