Utopia  2
Framework for studying models of complex & adaptive systems.
Functions
Graph Utilities

Provides functions which wrap common tasks for writing out data from graphs. More...

Collaboration diagram for Graph Utilities:

Functions

template<typename Graph >
std::shared_ptr< HDFGroupUtopia::DataIO::create_graph_group (const Graph &g, const std::shared_ptr< HDFGroup > &parent_grp, const std::string &name)
 
template<typename Graph >
void Utopia::DataIO::save_graph (const Graph &g, const std::shared_ptr< HDFGroup > &grp)
 Write function for a boost::Graph. More...
 
template<typename Graph , typename PropertyMap >
void Utopia::DataIO::save_graph (const Graph &g, const std::shared_ptr< HDFGroup > &grp, const PropertyMap vertex_ids)
 Write function for a boost::Graph. More...
 
template<IterateOver iterate_over, typename Graph , typename... Adaptors>
void Utopia::DataIO::save_graph_entity_properties (const Graph &g, const std::shared_ptr< HDFGroup > &nw_grp, const std::string &label, const std::tuple< Adaptors... > &adaptor_tuple)
 
template<typename Graph , typename... Adaptors>
void Utopia::DataIO::save_vertex_properties (Graph &&g, const std::shared_ptr< HDFGroup > &nw_grp, const std::string &label, const std::tuple< Adaptors... > &adaptor_tuple)
 
template<typename Graph , typename... Adaptors>
void Utopia::DataIO::save_edge_properties (Graph &&g, const std::shared_ptr< HDFGroup > &nw_grp, const std::string &label, const std::tuple< Adaptors... > &adaptor_tuple)
 

Detailed Description

Provides functions which wrap common tasks for writing out data from graphs.

Graph Utilities Module

Overview

This module implements functions which wrap common tasks people face when they wish to extract data from boost::graph objects.

Implementation

The provided functions can be separated into two groups, one which saves the entire graph, i.e., its edge-vertex structure, and a second one which allows to extract data associated with either edges or vertices via user supplied functions.

Function Documentation

◆ create_graph_group()

template<typename Graph >
std::shared_ptr<HDFGroup> Utopia::DataIO::create_graph_group ( const Graph &  g,
const std::shared_ptr< HDFGroup > &  parent_grp,
const std::string &  name 
)

This function opens a HDFGroup for graph data and adds attributes.

The attributes that are set mark the newly created group as containing network data and add some graph metadata like whether the graph is directed and/or allows parallel edges.

Template Parameters
Graph
Parameters
gThe graph to save
parent_grpThe parent HDFGroup the graph data should be stored in
nameThe name the newly created graph group should have
Returns
std::shared_ptr<HDFGroup> The newly created graph group

◆ save_edge_properties()

template<typename Graph , typename... Adaptors>
void Utopia::DataIO::save_edge_properties ( Graph &&  g,
const std::shared_ptr< HDFGroup > &  nw_grp,
const std::string &  label,
const std::tuple< Adaptors... > &  adaptor_tuple 
)

This function writes the results of all functions in a named tuple, applied to all edges of a boost::graph into a HDFGroup.

This function calls the general save_graph_entity_properties method using IterateOver::edges. See Utopia::DataIO::save_graph_entity_properties for more detail.

Template Parameters
Graph
Adaptors
Parameters
gThe graph from which to save edge properties.
nw_grpThe HDFGroup the data should be written to.
labelUnder which label the results of the adaptors should be stored.
adaptor_tupleWhich edge-associated properties to write.
Returns
void

◆ save_graph() [1/2]

template<typename Graph >
void Utopia::DataIO::save_graph ( const Graph &  g,
const std::shared_ptr< HDFGroup > &  grp 
)

Write function for a boost::Graph.

This function writes a boost::graph into a HDFGroup. It assumes that the vertices and edges of the graph already supply indices.

Template Parameters
Graph
Parameters
gThe graph to save
grpThe HDFGroup the graph should be stored in
Returns
void

◆ save_graph() [2/2]

template<typename Graph , typename PropertyMap >
void Utopia::DataIO::save_graph ( const Graph &  g,
const std::shared_ptr< HDFGroup > &  grp,
const PropertyMap  vertex_ids 
)

Write function for a boost::Graph.

This function writes a boost::graph into a HDFGroup. By supplying custom vertex IDs, they need not be part of the graph in order for this function to operate.

Template Parameters
Graph
PropertyMapThe property map of the vertex ids
Parameters
gThe graph to save
grpThe HDFGroup the graph should be stored in
vertex_idsA custom property map of vertex IDs to use
Returns
void

◆ save_graph_entity_properties()

template<IterateOver iterate_over, typename Graph , typename... Adaptors>
void Utopia::DataIO::save_graph_entity_properties ( const Graph &  g,
const std::shared_ptr< HDFGroup > &  nw_grp,
const std::string &  label,
const std::tuple< Adaptors... > &  adaptor_tuple 
)

This function writes the results of all functions in a named tuple, applied to all vertices/edges of a boost::graph into a HDFGroup.

For each adaptor, the data written by this function is available at the path nw_grp/adaptor_name/label, where label is a dataset of size {num_edges/vertices} in the 1d case or {num_adaptors, num_edges/vertices} if data from more than one adaptor is to be written.

Attributes are added to the datasets that determine the dimension names and the coordinates. The name of dimension -1 is set to vertex_idx/edge_idx. The respective coordinates are the trivial ones. In the case of 2d data custom dimension name and coordinates for dimension need to be given. Note that the former has to be string-like and the latter have to be of the same type.

Warning
The coordinate type is deduced from the first coordinate. All other coordinates have to be of the same type.
Template Parameters
IterateOverThe type of iterator that is used to access the graph. The entity properties can be accessed either via edge-descriptors (IterateOver::edges) or via vertex-descriptors (IterateOver::vertices).
Graph
Adaptors
Parameters
gThe graph from which to save vertex or edge properties.
nw_grpThe HDFGroup the data should be written to. This should be the previously created network group. For each tuple entry, a new group will be created, which has the name specified as first element of that tuple.
labelUnder which label the results of the adaptors should be stored. This will be the name of the dataset to which the adaptors write data. If time-varying data is to be written, this can be used to specify the time step.
adaptor_tupleWhich vertex- or edge-associated properties to write. This should be a tuple of tuples, where the latter are of one of the following forms: If (adaptor_name, adaptor) then 1d data is written. If (adaptor_name, dim0_name, (coord1, adaptor1), (coord2, adaptor2), ...) then 2d data is written.
Returns
void

◆ save_vertex_properties()

template<typename Graph , typename... Adaptors>
void Utopia::DataIO::save_vertex_properties ( Graph &&  g,
const std::shared_ptr< HDFGroup > &  nw_grp,
const std::string &  label,
const std::tuple< Adaptors... > &  adaptor_tuple 
)

This function writes the results of all functions in a named tuple, applied to all vertices of a boost::graph into a HDFGroup.

This function calls the general save_graph_entity_properties method using IterateOver::vertices. See Utopia::DataIO::save_graph_entity_properties for more detail.

Template Parameters
Graph
Adaptors
Parameters
gThe graph from which to save vertex properties.
nw_grpThe HDFGroup the data should be written to.
labelUnder which label the results of the adaptors should be stored.
adaptor_tupleWhich vertex–associated properties to write.
Returns
void