Construct version 5.4.4
An agent based modeling framework
graph_utils Namespace Reference

Definitions for iterators, helper functions, and operators that support Graph. More...

Classes

struct  col_begin_iterator
 An iterator that iterates over the start of each row. More...
 
struct  col_graph_iterator
 An iterator parent for iterators that increment through a column. More...
 
struct  const_col_begin_iterator
 A constant iterator that iterates over the start of each column. More...
 
struct  const_full_col_iterator
 A constant iterator that iterates over every row at a constant column. More...
 
struct  const_full_row_iterator
 A constant iterator that iterates over every column at a constant row. More...
 
struct  const_row_begin_iterator
 A constant iterator that iterates over the start of each row. More...
 
struct  const_sparse_col_iterator
 A constant iterator that iterates over each element whose value does not equal the skip value. More...
 
struct  const_sparse_row_iterator
 A constant iterator that iterates over each element whose value does not equal the skip value. More...
 
struct  full_col_iterator
 An iterator that iterates over every row at a constant column. More...
 
struct  full_row_iterator
 An iterator that iterates over every column at a constant row. More...
 
struct  graph_iterator
 Finds the next index that aligns iterators. More...
 
struct  row_begin_iterator
 An iterator that iterates over the start of each row. More...
 
struct  row_graph_iterator
 An iterator parent for iterators that increment through a row. More...
 
struct  sparse_col_iterator
 An iterator that iterates over each element whose value does not equal the skip value. More...
 
struct  sparse_graph_iterator
 An iterator parent for sparse iterators that stores the value that the iterators must skip over when incrementing. More...
 
struct  sparse_row_iterator
 An iterator that iterates over each element whose value does not equal the skip value. More...
 

Functions

template<typename it1 , typename it2 , typename... its>
auto it_align (it1 first_iterator, it2 second_iterator, its... extra_iterators)
 Function that zips the iterators passed to it and keeps all the iterators aligned with each other. More...
 
template<typename it1 , typename it2 , typename... its>
auto it_misalign (it1 misaligned_iterator, it2 second_iterator, its... extra_iterators)
 Function that zips the iterators passed to it and keeps all but the first iterators aligned with each other. More...
 
template<typename T >
void check_range (const Graph< T > &graph, const T &lower_bound, const T &upper_bound)
 
template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > ewise_product (const Graph< left > &lhs, const Graph< right > &rhs, bool row_dense, bool col_dense)
 
template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > ewise_product (const Graph< left > &lhs, const Graph< right > &rhs)
 
template<typename left , typename right >
auto ewise_product (const Temporary_Graph< left > &lhs, const Graph< right > &rhs)
 
template<typename left , typename right >
auto ewise_product (const Graph< left > &lhs, const Temporary_Graph< right > &rhs)
 
template<typename left , typename right >
auto ewise_product (const Temporary_Graph< left > &lhs, const Temporary_Graph< right > &rhs)
 
template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > ewise_product (const Graph< left > &lhs, const Transpose< right > &rhs, bool row_dense, bool col_dense)
 
template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > ewise_product (const Graph< left > &lhs, const Transpose< right > &rhs)
 
template<typename left , typename right >
auto ewise_product (const Transpose< left > &lhs, const Graph< right > &rhs)
 
template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > ewise_product (const Transpose< left > &lhs, const Transpose< right > &rhs, bool row_dense, bool col_dense)
 
template<typename left , typename right >
auto ewise_product (const Transpose< left > &lhs, const Transpose< right > &rhs)
 
template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > ewise_divide (const Graph< left > &lhs, const Graph< right > &rhs, bool row_dense, bool col_dense)
 
template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > ewise_divide (const Graph< left > &lhs, const Graph< right > &rhs)
 
template<typename left , typename right >
auto ewise_divide (const Temporary_Graph< left > &lhs, const Graph< right > &rhs)
 
template<typename left , typename right >
auto ewise_divide (const Graph< left > &lhs, const Temporary_Graph< right > &rhs)
 
template<typename left , typename right >
auto ewise_divide (const Temporary_Graph< left > &lhs, const Temporary_Graph< right > &rhs)
 
template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > ewise_divide (const Graph< left > &lhs, const Transpose< right > &rhs, bool row_dense, bool col_dense)
 
template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > ewise_divide (const Graph< left > &lhs, const Transpose< right > &rhs)
 
template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > ewise_divide (const Transpose< left > &lhs, const Graph< right > &rhs, bool row_dense, bool col_dense)
 
template<typename left , typename right >
auto ewise_divide (const Transpose< left > &lhs, const Graph< right > &rhs)
 
template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > ewise_divide (const Transpose< left > &lhs, const Transpose< right > &rhs, bool row_dense, bool col_dense)
 
template<typename left , typename right >
auto ewise_divide (const Transpose< left > &lhs, const Transpose< right > &rhs)
 
template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > dot_product (const Graph< left > &lhs, const Graph< right > &rhs, bool output_row_dense, bool output_col_dense)
 
template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > dot_product (const Graph< left > &lhs, const Transpose< right > &rhsT, bool output_row_dense, bool output_col_dense)
 
template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > dot_product (const Transpose< left > &lhsT, const Graph< right > &rhs, bool output_row_dense, bool output_col_dense)
 

Variables

static constexpr unsigned char transform [16]
 

Detailed Description

Definitions for iterators, helper functions, and operators that support Graph.

Function Documentation

◆ check_range()

template<typename T >
void graph_utils::check_range ( const Graph< T > &  graph,
const T &  lower_bound,
const T &  upper_bound 
)

summary>

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dot_product() [1/2]

template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > graph_utils::dot_product ( const Graph< left > &  lhs,
const Graph< right > &  rhs,
bool  output_row_dense,
bool  output_col_dense 
)

summary>

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dot_product() [2/2]

template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > graph_utils::dot_product ( const Graph< left > &  lhs,
const Transpose< right > &  rhsT,
bool  output_row_dense,
bool  output_col_dense 
)

summary>

Here is the call graph for this function:

◆ ewise_divide() [1/10]

template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > graph_utils::ewise_divide ( const Graph< left > &  lhs,
const Graph< right > &  rhs 
)

summary>

Here is the call graph for this function:

◆ ewise_divide() [2/10]

template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > graph_utils::ewise_divide ( const Graph< left > &  lhs,
const Graph< right > &  rhs,
bool  row_dense,
bool  col_dense 
)

summary>

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ewise_divide() [3/10]

template<typename left , typename right >
auto graph_utils::ewise_divide ( const Graph< left > &  lhs,
const Temporary_Graph< right > &  rhs 
)

summary>

Here is the call graph for this function:

◆ ewise_divide() [4/10]

template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > graph_utils::ewise_divide ( const Graph< left > &  lhs,
const Transpose< right > &  rhs 
)

summary>

Here is the call graph for this function:

◆ ewise_divide() [5/10]

template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > graph_utils::ewise_divide ( const Graph< left > &  lhs,
const Transpose< right > &  rhs,
bool  row_dense,
bool  col_dense 
)

summary>

Here is the call graph for this function:

◆ ewise_divide() [6/10]

template<typename left , typename right >
auto graph_utils::ewise_divide ( const Temporary_Graph< left > &  lhs,
const Graph< right > &  rhs 
)

summary>

Here is the call graph for this function:

◆ ewise_divide() [7/10]

template<typename left , typename right >
auto graph_utils::ewise_divide ( const Temporary_Graph< left > &  lhs,
const Temporary_Graph< right > &  rhs 
)

summary>

Here is the call graph for this function:

◆ ewise_divide() [8/10]

template<typename left , typename right >
auto graph_utils::ewise_divide ( const Transpose< left > &  lhs,
const Graph< right > &  rhs 
)

summary>

Here is the call graph for this function:

◆ ewise_divide() [9/10]

template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > graph_utils::ewise_divide ( const Transpose< left > &  lhs,
const Graph< right > &  rhs,
bool  row_dense,
bool  col_dense 
)

summary>

Here is the call graph for this function:

◆ ewise_divide() [10/10]

template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > graph_utils::ewise_divide ( const Transpose< left > &  lhs,
const Transpose< right > &  rhs,
bool  row_dense,
bool  col_dense 
)

summary>

Here is the call graph for this function:

◆ ewise_product() [1/10]

template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > graph_utils::ewise_product ( const Graph< left > &  lhs,
const Graph< right > &  rhs 
)

summary>

Here is the call graph for this function:

◆ ewise_product() [2/10]

template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > graph_utils::ewise_product ( const Graph< left > &  lhs,
const Graph< right > &  rhs,
bool  row_dense,
bool  col_dense 
)

summary>

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ewise_product() [3/10]

template<typename left , typename right >
auto graph_utils::ewise_product ( const Graph< left > &  lhs,
const Temporary_Graph< right > &  rhs 
)

summary>

Here is the call graph for this function:

◆ ewise_product() [4/10]

template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > graph_utils::ewise_product ( const Graph< left > &  lhs,
const Transpose< right > &  rhs 
)

summary>

Here is the call graph for this function:

◆ ewise_product() [5/10]

template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > graph_utils::ewise_product ( const Graph< left > &  lhs,
const Transpose< right > &  rhs,
bool  row_dense,
bool  col_dense 
)

summary>

Here is the call graph for this function:

◆ ewise_product() [6/10]

template<typename left , typename right >
auto graph_utils::ewise_product ( const Temporary_Graph< left > &  lhs,
const Graph< right > &  rhs 
)

summary>

Here is the call graph for this function:

◆ ewise_product() [7/10]

template<typename left , typename right >
auto graph_utils::ewise_product ( const Temporary_Graph< left > &  lhs,
const Temporary_Graph< right > &  rhs 
)

summary>

Here is the call graph for this function:

◆ ewise_product() [8/10]

template<typename left , typename right >
auto graph_utils::ewise_product ( const Transpose< left > &  lhs,
const Graph< right > &  rhs 
)

summary>

Here is the call graph for this function:

◆ ewise_product() [9/10]

template<typename left , typename right >
auto graph_utils::ewise_product ( const Transpose< left > &  lhs,
const Transpose< right > &  rhs 
)

summary>

Here is the call graph for this function:

◆ ewise_product() [10/10]

template<typename left , typename right , class output = decltype(left()* right())>
Temporary_Graph< output > graph_utils::ewise_product ( const Transpose< left > &  lhs,
const Transpose< right > &  rhs,
bool  row_dense,
bool  col_dense 
)

summary>

Here is the call graph for this function:

◆ it_align()

template<typename it1 , typename it2 , typename... its>
auto graph_utils::it_align ( it1  first_iterator,
it2  second_iterator,
its...  extra_iterators 
)

Function that zips the iterators passed to it and keeps all the iterators aligned with each other.

Iterators passed to the function are copied instead of stored by reference. The function constructs a class that contains all the iterators and the logic for advancing all iterators. The returned object is intended to be used in a for loop with the colon syntax. This will yield a loop variable which is a tuple containing all the iterators. Each loop will return this tuple with all iterators having equal typeless_graph_iterator::index values. The loop will continue until the iterator's index has reached its typeless_graph_iterator::max value.

Parameters
first_iteratorIterator that all other iterators align to.
second_iteratorAn iterator that gets aligned.
extra_iteratorsAll other iterators to be included in the alignment.

Example

int main()
{
// Graph is loaded in with the following data
// 0 1 0 2
// 0 1 3 1
// 1 1 0 0
// 1 0 0 2
Graph<int>& my_graph = construct.load_required("my network", "my nodeset", "my nodeset");
int count = 0;
for (auto& [it0, it1] : graph_utils::it_align(my_graph.get_row(0).sparse(0), my_graph.get_row(1).sparse(0))) {
count++;
}
std::cout << "Intersect of row 0 and row 1 is " << count << std::endl;
count = 0;
for (auto& [it0, it1, it2, it3] : graph_utils::it_align(
my_graph.get_row(0).sparse(0),
my_graph.get_row(1).sparse(3),
my_graph.get_row(2).full(),
my_graph.get_row(3).sparse(1))) {
count += *it0 + *it1 + *it2 + *it3;
}
std::cout << "Custom calculation of graph is " << count << std::endl;
}
Data structure for storing graphs/networks.
Definition: Graph.h:989
virtual row_begin_iterator get_row(unsigned int row_index)=0
Returns an iterator pointing to the specified row.
auto it_align(it1 first_iterator, it2 second_iterator, its... extra_iterators)
Function that zips the iterators passed to it and keeps all the iterators aligned with each other.
Definition: Graph_utils.h:212

Output:

Intersect of row 0 and row 1 is 2
Custom calculation of graph is 8

Complexity

Depends on the underlying data structure that the iterators points to. At best O(n) with n being the number of iterators and O(n*m) with m being the size of the dimension.

Iterator validity

Does not inheriently modify the underlying data structure that the iterators point to.

Exception Safety

An assertion is raised if the dimension that any iterator iterates over does not have the same size as all other iterators.

Here is the caller graph for this function:

◆ it_misalign()

template<typename it1 , typename it2 , typename... its>
auto graph_utils::it_misalign ( it1  misaligned_iterator,
it2  second_iterator,
its...  extra_iterators 
)

Function that zips the iterators passed to it and keeps all but the first iterators aligned with each other.

Iterators passed to the function are copied instead of stored by reference. The function constructs a class that contains all the iterators and the logic for advancing all iterators. The returned object is intended to be used in a for loop with the colon syntax. This will yield a loop variable which is a tuple containing all the iterators. Each loop will return this tuple with all iterators after the first having equal typeless_graph_iterator::index values and the first iterator having a greater value than that. The loop will continue until all execpt the first iterator's index has reached its typeless_graph_iterator::max value.

Parameters
misaligned_iteratorIterator that all is always misaligned with all other iterators.
second_iteratorIterator that all other iterators except the first iterator gets aligned to.
extra_iteratorsAll other iterators to be included in the alignment.

Example

int main()
{
// Graph is loaded in with the following data
// 0 1 0 2
// 0 1 3 1
// 1 1 0 0
// 1 0 0 2
Graph<int>& my_graph = construct.load_required("my network", "my nodeset", "my nodeset");
int count = 0;
for (auto& [it0, it1] : graph_utils::it_misalign(my_graph.get_row(0).sparse(0), my_graph.get_row(1).sparse(0))) {
count++;
}
std::cout << "Intersect of not row 0 and row 1 is " << count << std::endl;
count = 0;
// second and fourth column are skipped because they contain an element that isn't skipped by all iterators
for (auto& [it0, it1, it2, it3] : graph_utils::it_align(
my_graph.get_row(0).sparse(0),
my_graph.get_row(1).sparse(1),
my_graph.get_row(2).sparse(3),
my_graph.get_row(3).sparse(2))) {
count += *it0 + *it1 + *it2 + *it3;
}
std::cout << "Custom calculation of graph is " << count << std::endl;
}
auto it_misalign(it1 misaligned_iterator, it2 second_iterator, its... extra_iterators)
Function that zips the iterators passed to it and keeps all but the first iterators aligned with each...
Definition: Graph_utils.h:290

Output:

Overlap of row 0 and row 1 is 2
Custom calculation of graph is 5

Complexity

Depends on the underlying data structure that the iterators points to. At best O(n) with n being the number of iterators and O(n*m) with m being the size of the dimension.

Iterator validity

Does not inheriently modify the underlying data structure that the iterators point to.

Exception Safety

An assertion is raised if the dimension that any iterator iterates over does not have the same size as all other iterators.

Here is the caller graph for this function:

Variable Documentation

◆ transform

constexpr unsigned char graph_utils::transform[16]
staticconstexpr
Initial value:
= {
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
2,
3,
0,
3,
2,
3
}

summary>