51#include <lal/linear_arrangement.hpp>
52#include <lal/numeric/rational.hpp>
53#include <lal/linarr/D.hpp>
54#include <lal/utilities/aggregations.hpp>
85template <
class graph_t>
87(
const std::vector<graph_t>& L,
const std::vector<linear_arrangement>& P = {})
90 static_assert(std::is_base_of_v<graphs::graph, graph_t>);
95 assert(P.size() == 0 or L.size() == P.size());
103#define IDE linear_arrangement::identity(G.get_num_nodes())
104 return utilities::two_level_aggregation<ratio, true>
106 L.begin(), L.end(),
nullptr,
nullptr,
108 [](
const graph_t& G) { return mean_dependency_distance_rational(G, IDE); },
110 [](
const ratio& MDD) { return MDD; },
112 [](ratio& total,
const ratio& MDD) { total += MDD; },
114 [](
const ratio& sum_MDD, std::size_t num_graphs) { return sum_MDD/num_graphs; }
120 return utilities::two_level_aggregation<ratio, false>
122 L.begin(), L.end(), P.begin(), P.end(),
124 [](
const graph_t& G,
const ARR& arr) { return mean_dependency_distance_rational(G, arr); },
126 [](
const ratio& MDD) { return MDD; },
128 [](ratio& sum_MDD,
const ratio& MDD) { sum_MDD += MDD; },
130 [](
const ratio& sum_MDD, std::size_t num_graphs) { return sum_MDD/num_graphs; }
149template <
class graph_t>
151(
const std::vector<graph_t>& L,
const std::vector<linear_arrangement>& P = {})
Linear arrangement of vertices.
Definition: linear_arrangement.hpp:103
Exact rational number.
Definition: rational.hpp:63
double to_double() const noexcept
Converts this rational to a double-precision floating-point value.
Definition: rational.hpp:850
numeric::rational mean_dependency_distance_2level_rational(const std::vector< graph_t > &L, const std::vector< linear_arrangement > &P={}) noexcept
2-level Mean Dependency Distance over an ensemble of graphs.
Definition: 2level.hpp:87
double mean_dependency_distance_2level(const std::vector< graph_t > &L, const std::vector< linear_arrangement > &P={}) noexcept
2-level Mean Dependency Distance over an ensemble of graphs.
Definition: 2level.hpp:151
Main namespace of the library.
Definition: basic_types.hpp:50