Utopia 2
Framework for studying models of complex & adaptive systems.
|
Provides functions which wrap common tasks for writing out data from graphs. More...
Functions | |
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) |
template<typename Graph > | |
void | Utopia::DataIO::save_graph (const Graph &g, const std::shared_ptr< HDFGroup > &grp) |
Write function for a boost::Graph. | |
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. | |
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) |
Provides functions which wrap common tasks for writing out data from graphs.
This module implements functions which wrap common tasks people face when they wish to extract data from boost::graph objects.
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.
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.
Graph |
g | The graph to save |
parent_grp | The parent HDFGroup the graph data should be stored in |
name | The name the newly created graph group should have |
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.
Graph | |
Adaptors |
g | The graph from which to save edge properties. |
nw_grp | The HDFGroup the data should be written to. |
label | Under which label the results of the adaptors should be stored. |
adaptor_tuple | Which edge-associated properties to write. |
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.
Graph |
g | The graph to save |
grp | The HDFGroup the graph should be stored in |
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.
Graph | |
PropertyMap | The property map of the vertex ids |
g | The graph to save |
grp | The HDFGroup the graph should be stored in |
vertex_ids | A custom property map of vertex IDs to use |
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.
IterateOver | The 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 |
g | The graph from which to save vertex or edge properties. |
nw_grp | The 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. |
label | Under 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_tuple | Which 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. |
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.
Graph | |
Adaptors |
g | The graph from which to save vertex properties. |
nw_grp | The HDFGroup the data should be written to. |
label | Under which label the results of the adaptors should be stored. |
adaptor_tuple | Which vertex–associated properties to write. |