|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Random directed graph (digraph) generator. More...
#include <random_graph.H>
Private Types | |
| typedef GT::Node | GT_Node |
| typedef GT::Arc | GT_Arc |
Private Member Functions | |
| bool | verify_tables () |
| virtual void | update_parity_after_arc_insertion (GT_Node *src, GT_Node *tgt) |
| void | create_nodes_and_initialize_arc_index () override |
| void | connect () override |
| GT | create_p (const size_t &__num_nodes, const double &p, bool connected) override |
| void | make_eulerian () override |
| void | balance_digraph_node (GT_Node *p) |
| void | balance_digraph_nodes_degree (GT_Node *src, GT_Node *tgt) |
| void | make_hamiltonian () override |
Private Attributes | |
| DynSetRandTree< GT_Node * > | greater |
| DynSetRandTree< GT_Node * > | smaller |
| DynSetRandTree< GT_Node * > | equal |
Random directed graph (digraph) generator.
Random_Digraph is a class for generating random directed graphs with a specified number of nodes and, depending on the invoked operation, a specified number of arcs or arc probability.
The class exports two generation methods via the function-call operator, intended for generating sparse and dense digraphs respectively.
Template parameters:
Definition at line 739 of file random_graph.H.
|
private |
Definition at line 742 of file random_graph.H.
|
private |
Definition at line 741 of file random_graph.H.
|
inline |
Constructor.
| [in] | seed | Seed for the random number generator. |
| [in] | __init_node | Node initialization functor. |
| [in] | __init_arc | Arc initialization functor. |
Definition at line 994 of file random_graph.H.
References Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::g, and GraphCommon< GT, Node, Arc >::set_digraph().
|
inline |
Definition at line 1002 of file random_graph.H.
|
inline |
Definition at line 1010 of file random_graph.H.
|
inline |
Definition at line 1017 of file random_graph.H.
References Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::g, and GraphCommon< GT, Node, Arc >::set_digraph().
|
inlineprivate |
Definition at line 1110 of file random_graph.H.
References Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::g, GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::get_num_nodes(), Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::idx_arc, Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::insert_arc(), Aleph::maps(), NODE_COUNTER, Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::nodes, and Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::r.
Referenced by Aleph::Random_Digraph< GT, Init_Node, Init_Arc >::balance_digraph_nodes_degree().
|
inlineprivate |
Definition at line 1137 of file random_graph.H.
References Aleph::Random_Digraph< GT, Init_Node, Init_Arc >::balance_digraph_node(), Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::g, GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::get_num_nodes(), Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::idx_arc, Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::insert_arc(), Aleph::maps(), NODE_COUNTER, Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::nodes, and Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::r.
Referenced by Aleph::Random_Digraph< GT, Init_Node, Init_Arc >::make_hamiltonian().
|
inlineoverrideprivatevirtual |
Implements Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >.
Definition at line 906 of file random_graph.H.
References Aleph::DynArray< T >::access(), Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::g, GraphCommon< GT, Node, Arc >::get_num_nodes(), Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::idx_arc, Aleph::in_degree(), Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::insert_arc(), Aleph::maps(), NODE_COUNTER, Aleph::DynArray< T >::reserve(), Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::select_random_node(), and Aleph::HTList::size().
Referenced by Aleph::Random_Digraph< GT, Init_Node, Init_Arc >::create_p().
|
inlineoverrideprivatevirtual |
Implements Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >.
Definition at line 883 of file random_graph.H.
References Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::g, Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::idx_arc, Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::init_node, Aleph::DynSetTree< Key, Tree, Compare >::insert(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), Aleph::maps(), NODE_COUNTER, Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::nodes, Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::num_nodes, and Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::save_parity.
|
inlineoverrideprivatevirtual |
Implements Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >.
Definition at line 962 of file random_graph.H.
References ah_domain_error_if, Aleph::Random_Digraph< GT, Init_Node, Init_Arc >::connect(), Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::g, Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::idx_arc, Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::initialize_and_create_nodes(), Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::insert_arc(), Aleph::maps(), Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::nodes, Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::num_nodes, and Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::r.
Referenced by Aleph::Random_Digraph< GT, Init_Node, Init_Arc >::operator()().
|
inlineoverrideprivatevirtual |
Implements Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >.
Definition at line 1075 of file random_graph.H.
References Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::idx_arc, Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::insert_arc(), Aleph::maps(), Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::r, Aleph::DynSetTree< Key, Tree, Compare >::select(), Aleph::DynSetTree< Key, Tree, Compare >::size(), and Aleph::HTList::size().
|
inlineoverrideprivatevirtual |
Implements Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >.
Definition at line 1174 of file random_graph.H.
References Aleph::Random_Digraph< GT, Init_Node, Init_Arc >::balance_digraph_nodes_degree(), Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::g, GraphCommon< GT, Node, Arc >::get_num_nodes(), NODE_COUNTER, Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::nodes, and GraphCommon< GT, Node, Arc >::reset_counter_nodes().
|
inline |
Create a random digraph with arc probability.
This version builds a random digraph with probability p of an arc existing between any ordered pair of nodes.
Use this routine to generate dense digraphs. In this case, use a value of p greater than or equal to 0.5.
The procedure is quadratic: all ordered node pairs are enumerated, and for each pair (i, j) a random draw with probability p determines whether an arc is created.
__num_nodes increases.| [in] | __num_nodes | Number of nodes the digraph should have. |
| [in] | p | Probability of an arc existing between any ordered pair of nodes. |
| [in] | connected | Whether the generated digraph should be strongly connected. Defaults to true. |
| bad_alloc | if there is not enough memory. |
| domain_error | if p is not in the range (0, 1]. |
Definition at line 1068 of file random_graph.H.
References Aleph::Random_Digraph< GT, Init_Node, Init_Arc >::create_p(), and Aleph::maps().
|
inline |
Create a sparse random digraph.
This version builds a random digraph with approximately __num_arcs arcs. The digraph contains no parallel arcs.
The randomization procedure selects two nodes at random and inserts an arc between them if one does not already exist. The routine is linear, proportional to __num_arcs.
| [in] | __num_nodes | Number of nodes the digraph should have. |
| [in] | __num_arcs | Number of arcs the digraph should have. |
| [in] | connected | Whether the generated digraph should be strongly connected. Defaults to true. |
| bad_alloc | if there is not enough memory. |
Definition at line 1038 of file random_graph.H.
References Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::create(), and Aleph::maps().
|
inlineprivatevirtual |
Implements Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >.
Definition at line 833 of file random_graph.H.
References Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::g, GraphCommon< GT, Node, Arc >::get_num_arcs(), Aleph::DynSetTree< Key, Tree, Compare >::insert(), Aleph::maps(), NODE_COUNTER, Aleph::DynSetTree< Key, Tree, Compare >::remove(), Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::save_parity, and Aleph::DynSetTree< Key, Tree, Compare >::search().
|
inlineprivate |
Definition at line 748 of file random_graph.H.
References Aleph::Random_Digraph< GT, Init_Node, Init_Arc >::equal, Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::g, GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::get_num_nodes(), Aleph::maps(), NODE_COUNTER, Aleph::Random_Graph_Base< GT, Init_Node, Init_Arc >::nodes, Aleph::DynSetTree< Key, Tree, Compare >::search(), Aleph::DynSetTree< Key, Tree, Compare >::size(), and Aleph::Random_Digraph< GT, Init_Node, Init_Arc >::smaller.
|
private |
Definition at line 746 of file random_graph.H.
Referenced by Aleph::Random_Digraph< GT, Init_Node, Init_Arc >::verify_tables().
|
private |
Definition at line 744 of file random_graph.H.
|
private |
Definition at line 745 of file random_graph.H.
Referenced by Aleph::Random_Digraph< GT, Init_Node, Init_Arc >::verify_tables().