Utopia  2
Framework for studying models of complex & adaptive systems.
Functions
Utopia::GraphUtils Namespace Reference

Functions

template<typename Graph , typename Iter , typename Rule >
void apply_async (Iter it_begin, Iter it_end, Graph &&g, Rule &&rule)
 Apply a rule asynchronously. More...
 
template<typename Iter , typename Graph , typename Rule >
void apply_sync (Iter it_begin, Iter it_end, Graph &&g, Rule &&rule)
 Apply a rule synchronously. More...
 
template<IterateOver iterate_over, typename Graph >
decltype(auto) iterator_pair (const Graph &g)
 Get an iterator pair over selected graph entities. More...
 
template<IterateOver iterate_over, typename Graph , typename EntityDesc >
decltype(auto) iterator_pair (EntityDesc e, const Graph &g)
 Get an iterator pair over selected graph entities. More...
 

Function Documentation

◆ apply_async()

template<typename Graph , typename Iter , typename Rule >
void Utopia::GraphUtils::apply_async ( Iter  it_begin,
Iter  it_end,
Graph &&  g,
Rule &&  rule 
)

Apply a rule asynchronously.

This helper function applies a rule to a range of entities that is given through an iterator pair one after the other.

Template Parameters
IterThe iterator type
GraphThe graph type
RuleThe rule type
Parameters
it_beginThe begin of the graph entity iterator range.
it_endThe end of the graph entity iterator range.
gThe graph
ruleThe rule function to be applied to each element within the iterator range.

◆ apply_sync()

template<typename Iter , typename Graph , typename Rule >
void Utopia::GraphUtils::apply_sync ( Iter  it_begin,
Iter  it_end,
Graph &&  g,
Rule &&  rule 
)

Apply a rule synchronously.

This helper function applies a rule to a range of entities that is given through an iterator pair. A state cache is created that stores the returned states of the rule function. After the rule was applied to each graph entity within the iterator range the cached states are moved to the actual states of the graph entities, thus, updating their states synchronously.

Template Parameters
IterThe iterator type
GraphThe graph type
RuleThe rule type
Parameters
it_beginThe begin of the graph entity iterator range.
it_endThe end of the graph entity iterator range.
gThe graph
ruleThe rule function to be applied to each element within the iterator range.
Warning
Be careful to not operate directly on the state of a graph entity within the rule function. Rather, first create a copy of the state and return the copied and changed state at the end of the function.

◆ iterator_pair() [1/2]

template<IterateOver iterate_over, typename Graph >
decltype(auto) Utopia::GraphUtils::iterator_pair ( const Graph &  g)

Get an iterator pair over selected graph entities.

Template Parameters
iterate_overSpecify over which graph entities to iterate Valid options:
GraphThe graph type
Parameters
gThe graph
Returns
decltype(auto) The iterator pair

◆ iterator_pair() [2/2]

template<IterateOver iterate_over, typename Graph , typename EntityDesc >
decltype(auto) Utopia::GraphUtils::iterator_pair ( EntityDesc  e,
const Graph &  g 
)

Get an iterator pair over selected graph entities.

This function returns the iterator pair wrt. another graph entity. For example iteration over neighbors (adjacent_vertices) needs a references vertex.

Template Parameters
iterate_overSpecify over which graph entities to iterate over Valid options:
GraphThe graph type
EntityDescThe graph entity descriptor that is the reference point for the iteration.
Parameters
eThe graph entity that serves as reference
gThe graph
Returns
decltype(auto) The iterator pair