Random degreesequence network#
Undirected degreesequence network#
 random_degree_sequence_graph[vert_type](degree_sequence: List[int], random_state) undirected_network[vert_type] #

template<integer_network_vertex VertT, std::ranges::forward_range Range, std::uniform_random_bit_generator Gen>
requires degree_range<Range> && std::convertible_to<std::ranges::range_value_t<Range>, VertT>
undirected_network<VertT> random_degree_sequence_graph(Range °ree_sequence, Gen &generator)#
Generates a random undirected network where the degree sequence of vertices is
exactly equal to the input degree_sequence
. The output network has the
same number of nodes as the length of the degree_sequence
.
If the input degree_sequence
is not graphical, i.e., it is not possible
to create a graph that produces that sequence, the function fails by raising a
ValueError
exception in Python or a std::invalid_argument
exception
in C++.
The implementation is based on Ref. [4].
The generation of a random degreesequence graph becomes more and more difficult as the density increases. In C++, you can use the try_ variant of this function to limit runtime to a limited set of tries:

template<integer_network_vertex VertT, std::ranges::forward_range Range, std::uniform_random_bit_generator Gen>
requires degree_range<Range> && std::convertible_to<std::ranges::range_value_t<Range>, VertT>
std::optional<undirected_network<VertT>> try_random_degree_sequence_graph(Range °ree_sequence, Gen &generator, std::size_t max_tries)#
If this function succeeds in max_tries
tries, it will return the
resulting network, otherwise it returns an instance of std::nullopt_t
.
Directed degreesequence network#
 random_directed_degree_sequence_graph[vert_type](in_out_degree_sequence: List[Tuple[int, int]], random_state) directed_network[vert_type] #

template<integer_network_vertex VertT, std::ranges::forward_range PairRange, std::uniform_random_bit_generator Gen>
requires degree_pair_range<PairRange> && is_pairlike_of<std::ranges::range_value_t<PairRange>, VertT, VertT>
directed_network<VertT> random_directed_degree_sequence_graph(PairRange &in_out_degree_sequence, Gen &generator)#
Similar to the case of random degreesequence network, the directed variant
creates a graph that reproduces the input in_out_degree_sequence
for in
and outdegrees. The input in_out_degree_sequence
has to be a range of
pairlike objects, for example a vector of pairs
(std::vector<std::pair<VertT, VertT>>
) or a list of int
2tuple in
Python.
The implementation is based on an extension of Ref. [4].
Similar to undirected degreesequence network, this function also provides a try_ variant:

template<integer_network_vertex VertT, std::ranges::forward_range PairRange, std::uniform_random_bit_generator Gen>
requires degree_pair_range<PairRange> && is_pairlike_of<std::ranges::range_value_t<PairRange>, VertT, VertT>
std::optional<directed_network<VertT>> try_random_degree_sequence_graph(PairRange &in_out_degree_sequence, Gen &generator, std::size_t max_tries)#
If the input inoutdegree_sequence
is not digraphical, i.e., it is not
possible to create a directed graph that produces that in and outdegree
sequence, the funciton fails by raising a ValueError
exception in Python
or a std::invalid_argument
exception in C++.
If this function succeeds in max_tries
tries, it will return the
resulting network, otherwise it returns an instance of std::nullopt_t
.