50#include <lal/numeric/rational.hpp>
51#include <lal/graphs/undirected_graph.hpp>
52#include <lal/graphs/directed_graph.hpp>
53#include <lal/graphs/free_tree.hpp>
54#include <lal/graphs/rooted_tree.hpp>
61#if !defined __LAL_SWIG_PYTHON
76template <
class graph_t,
class return_type>
81 uint64_t (graph_t::*degree_function)(
node) const noexcept
86 std::is_same_v<return_type, uint64_t> ||
87 std::is_same_v<return_type, numeric::integer>
95 for (
node u = 0; u < g.get_num_nodes(); ++u) {
96 const uint64_t deg = (g.*degree_function)(u);
98 if constexpr (std::is_same_v<return_type, numeric::integer>) {
104 for (uint64_t i = 0; i < p; ++i) {
266 assert(t.is_rooted_tree());
268 return t.get_num_edges();
287 [[maybe_unused]]
const uint64_t p
292 assert(t.is_rooted_tree());
294 return t.get_num_edges();
343#if !defined __LAL_SWIG_PYTHON
359template <
class graph_t,
class return_type>
364 uint64_t (graph_t::*degree_function)(
node) const noexcept
369 std::is_floating_point_v<return_type> ||
370 std::is_same_v<return_type, numeric::rational>
373 if constexpr (std::is_floating_point_v<return_type>) {
376 return static_cast<return_type
>(S)/
static_cast<return_type
>(g.get_num_nodes());
531 [[maybe_unused]]
const uint64_t p
536 assert(t.is_rooted_tree());
538 const auto n = t.get_num_nodes();
555 [[maybe_unused]]
const uint64_t p
560 assert(t.is_rooted_tree());
562 const auto n = t.get_num_nodes();
563 return static_cast<double>(n - 1)/
static_cast<double>(n);
635 const uint64_t n = t.get_num_nodes();
648 return (k2_tree - k2_linear)/(k2_star - k2_linear);
674 const uint64_t n = t.get_num_nodes();
680 assert(t.is_rooted_tree());
687 return (k2_tree - k2_linear)/(k2_star - k2_linear);
703 const uint64_t n = t.get_num_nodes();
714 const double k2_linear =
static_cast<double>(4*n - 6)/
static_cast<double>(n);
715 const double k2_star =
static_cast<double>(n - 1);
716 return (k2_tree - k2_linear)/(k2_star - k2_linear);
733 const uint64_t n = t.get_num_nodes();
739 assert(t.is_rooted_tree());
744 const double k2_linear =
static_cast<double>(4*n - 6)/
static_cast<double>(n);
745 const double k2_star =
static_cast<double>(n - 1);
746 return (k2_tree - k2_linear)/(k2_star - k2_linear);
Directed graph class.
Definition directed_graph.hpp:67
uint64_t get_out_degree(const node u) const noexcept
Returns the out-degree of a node.
Definition directed_graph.hpp:420
uint64_t get_degree(const node u) const noexcept
Returns the in-degree plus the out-degree of this vertex.
Definition directed_graph.hpp:416
uint64_t get_in_degree(const node u) const noexcept
Returns the in-degree of a node.
Definition directed_graph.hpp:427
Free tree graph class.
Definition free_tree.hpp:60
Rooted tree graph class.
Definition rooted_tree.hpp:109
Undirected graph class.
Definition undirected_graph.hpp:66
uint64_t get_degree(const node u) const noexcept
Returns the number of neighbors of u.
Definition undirected_graph.hpp:384
Arbitrary precision integer.
Definition integer.hpp:60
Exact rational number.
Definition rational.hpp:63
numeric::rational moment_degree_rational(const graphs::undirected_graph &g, const uint64_t p) noexcept
Computes the -th moment of degree about zero of a graph as an exact rational value.
Definition degrees.hpp:403
return_type sum_powers_degrees(const graph_t &g, const uint64_t p, uint64_t(graph_t::*degree_function)(node) const noexcept) noexcept
Generic template function for the sum of degrees.
Definition degrees.hpp:78
numeric::rational hubiness_rational(const graphs::free_tree &t) noexcept
Computes the hubiness coefficient as an exact rational number.
Definition degrees.hpp:632
return_type moment_degree(const graph_t &g, const uint64_t p, uint64_t(graph_t::*degree_function)(node) const noexcept) noexcept
Generic template function for the moment of degree about 0.
Definition degrees.hpp:361
numeric::integer sum_powers_out_degrees_integer(const graphs::directed_graph &g, const uint64_t p) noexcept
Computes the sum of out-degrees raised to the -th power.
Definition degrees.hpp:312
double moment_out_degree(const graphs::directed_graph &g, const uint64_t p) noexcept
Computes the -th moment of out-degree about zero of a directed graph as a floating point value.
Definition degrees.hpp:600
uint64_t sum_powers_out_degrees(const graphs::directed_graph &g, const uint64_t p) noexcept
Computes the sum of out-degrees raised to the -th power.
Definition degrees.hpp:333
double hubiness(const graphs::free_tree &t) noexcept
Computes the hubiness coefficient as a floating point value.
Definition degrees.hpp:700
numeric::integer sum_powers_degrees_integer(const graphs::undirected_graph &g, const uint64_t p) noexcept
Computes the sum of degrees raised to the -th power.
Definition degrees.hpp:130
numeric::integer sum_powers_in_degrees_integer(const graphs::directed_graph &g, const uint64_t p) noexcept
Computes the sum of in-degrees raised to the -th power.
Definition degrees.hpp:216
uint64_t sum_powers_in_degrees(const graphs::directed_graph &g, const uint64_t p) noexcept
Computes the sum of in-degrees raised to the -th power.
Definition degrees.hpp:237
numeric::rational moment_in_degree_rational(const graphs::directed_graph &g, const uint64_t p) noexcept
Computes the -th moment of in-degree about zero of a directed graph as an exact rational value.
Definition degrees.hpp:485
numeric::rational moment_out_degree_rational(const graphs::directed_graph &g, const uint64_t p) noexcept
Computes the -th moment of out-degree about zero of a directed graph as an exact rational value.
Definition degrees.hpp:582
double moment_in_degree(const graphs::directed_graph &g, const uint64_t p) noexcept
Computes the -th moment of in-degree about zero of a directed graph as a floating point value.
Definition degrees.hpp:502
Main namespace of the library.
Definition basic_types.hpp:48
uint64_t node
Node type. See Node / Vertex page for further details.
Definition basic_types.hpp:51