|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Example demonstrating random graph generation in Aleph-w. More...
#include <iostream>#include <iomanip>#include <string>#include <tclap/CmdLine.h>#include <tpl_graph.H>#include <random_graph.H>#include <tpl_components.H>#include <eulerian.H>Go to the source code of this file.
Typedefs | |
| using | Node = Graph_Node< int > |
| using | Arc = Graph_Arc< double > |
| using | UGraph = List_Graph< Node, Arc > |
| using | DGraph = List_Digraph< Node, Arc > |
Functions | |
| void | print_section (const string &title) |
| void | print_subsection (const string &title) |
| template<typename G > | |
| void | print_graph_stats (const string &label, G &g) |
| void | demo_erdos_renyi () |
| void | demo_connected () |
| void | demo_eulerian () |
| void | demo_digraph () |
| void | demo_eulerian_digraph () |
| void | demo_parameters () |
| int | main (int argc, char *argv[]) |
Example demonstrating random graph generation in Aleph-w.
This program demonstrates random_graph.H which provides various models for generating random graphs. Random graphs are essential for algorithm testing, benchmarking, and research in graph theory.
Random graphs are useful for:
Model: Random graph with n vertices and m randomly placed edges
Properties:
Complexity: O(m) to generate
Applications:
Model: Random graph guaranteed to be connected
Algorithm:
Properties:
Complexity: O(m) to generate
Applications:
Model: Random graph with Eulerian cycle
Properties:
Algorithm:
Complexity: O(m + V) to generate
Applications:
Model: Directed version of random graphs
Properties:
Applications:
| Model | Connected? | Eulerian? | Cycles? | Degree Distribution |
|---|---|---|---|---|
| Erdős–Rényi | Maybe | Maybe | Maybe | Binomial |
| Connected | Always | Maybe | Usually | Varies |
| Eulerian | Usually | Always | Usually | All even |
| Digraph | Maybe | Maybe | Maybe | Asymmetric |
| Operation | Complexity | Notes |
|---|---|---|
| Generate G(n,m) | O(m) | Random edge placement |
| Generate connected | O(m) | Tree + random edges |
| Generate Eulerian | O(m + V) | Fix odd degrees |
| Generate digraph | O(m) | Directed edges |
Definition in file random_graph_example.C.
Definition at line 187 of file random_graph_example.C.
| using DGraph = List_Digraph<Node, Arc> |
Definition at line 189 of file random_graph_example.C.
| using Node = Graph_Node<int> |
Definition at line 186 of file random_graph_example.C.
| using UGraph = List_Graph<Node, Arc> |
Definition at line 188 of file random_graph_example.C.
| void demo_connected | ( | ) |
Definition at line 290 of file random_graph_example.C.
References Aleph::divide_and_conquer_partition_dp(), log(), m, print_graph_stats(), print_section(), and print_subsection().
Referenced by main().
| void demo_digraph | ( | ) |
Definition at line 374 of file random_graph_example.C.
References Aleph::divide_and_conquer_partition_dp(), m, max(), Aleph::Filter_Iterator< Container, It, Show_Item >::next(), print_section(), and print_subsection().
Referenced by main().
| void demo_erdos_renyi | ( | ) |
Definition at line 239 of file random_graph_example.C.
References Aleph::divide_and_conquer_partition_dp(), m, print_graph_stats(), print_section(), print_subsection(), and Aleph::to_string().
Referenced by main().
| void demo_eulerian | ( | ) |
Definition at line 328 of file random_graph_example.C.
References Aleph::divide_and_conquer_partition_dp(), GraphCommon< GT, Node, Arc >::get_node_it(), m, Aleph::Filter_Iterator< Container, It, Show_Item >::next(), print_graph_stats(), print_section(), print_subsection(), and test().
Referenced by main().
| void demo_eulerian_digraph | ( | ) |
Definition at line 419 of file random_graph_example.C.
References Aleph::divide_and_conquer_partition_dp(), m, print_section(), print_subsection(), and test().
Referenced by main().
| void demo_parameters | ( | ) |
Definition at line 452 of file random_graph_example.C.
References Aleph::divide_and_conquer_partition_dp(), log(), m, and print_section().
Referenced by main().
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 504 of file random_graph_example.C.
References cmd, demo_connected(), demo_digraph(), demo_erdos_renyi(), demo_eulerian(), demo_eulerian_digraph(), demo_parameters(), Aleph::divide_and_conquer_partition_dp(), and section().
Definition at line 208 of file random_graph_example.C.
References Aleph::divide_and_conquer_partition_dp(), GraphCommon< GT, Node, Arc >::get_node_it(), GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::get_num_nodes(), max(), min(), and Aleph::Filter_Iterator< Container, It, Show_Item >::next().
Referenced by demo_connected(), demo_erdos_renyi(), and demo_eulerian().
| void print_section | ( | const string & | title | ) |
Definition at line 195 of file random_graph_example.C.
Referenced by demo_connected(), demo_digraph(), demo_erdos_renyi(), demo_eulerian(), demo_eulerian_digraph(), and demo_parameters().
| void print_subsection | ( | const string & | title | ) |
Definition at line 202 of file random_graph_example.C.
Referenced by demo_connected(), demo_digraph(), demo_erdos_renyi(), demo_eulerian(), and demo_eulerian_digraph().