|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Cut nodes (articulation points), bridges, and biconnected components. More...
#include <iostream>#include <iomanip>#include <string>#include <vector>#include <tpl_graph.H>#include <tpl_cut_nodes.H>#include <tclap/CmdLine.h>Go to the source code of this file.
Typedefs | |
| using | Node = Graph_Node< string > |
| using | Arc = Graph_Arc< int > |
| using | Graph = List_Graph< Node, Arc > |
Functions | |
| Graph | build_network_graph () |
| Build a network with clear cut nodes. | |
| Graph | build_cyclic_graph () |
| Build a cyclic graph with fewer cut nodes. | |
| Graph | build_computer_network () |
| Build a graph representing a computer network. | |
| Graph::Node * | find_node (Graph &g, const string &name) |
| Find a node by name. | |
| void | print_graph (Graph &g, const string &title) |
| Print graph structure. | |
| void | demo_cut_nodes (Graph &g, const string &description) |
| Demonstrate finding cut nodes. | |
| void | demo_network_vulnerability () |
| Practical example: Network vulnerability analysis. | |
| void | demo_biconnected_components () |
| Demonstrate biconnected components. | |
| void | demo_resilience_comparison () |
| Compare resilient vs fragile networks. | |
| void | demo_bridges () |
| Demonstrate bridge finding with Compute_Bridges / find_bridges(). | |
| void | demo_fixing_vulnerabilities () |
| Demonstrate fixing network vulnerabilities. | |
| int | main (int argc, char *argv[]) |
Cut nodes (articulation points), bridges, and biconnected components.
Demonstrates algorithms for analyzing connectivity vulnerabilities in undirected graphs using Aleph-w:
Compute_Cut_Nodes, compute_cut_nodes()).Compute_Bridges, find_bridges()).Compute_Cut_Nodes::paint_subgraphs()).Both algorithms use Tarjan's DFS low-link technique.
Given a DFS, let df[v] = discovery time and low[v] = minimum discovery time reachable from v's subtree via back-edges.
u: DFS root with ≥ 2 children, OR non-root where low[child] >= df[u].(u, v) (tree edge): low[v] > df[u] — strictly greater, meaning no back-edge from v's subtree escapes above u.Graph = List_Graph<Graph_Node<string>, Graph_Arc<int>>string), arc info: int (unused in most demos).| Flag | Long | Description |
|---|---|---|
-b | --basic | Basic cut nodes demo |
-n | --network | Network vulnerability analysis |
-c | --biconnected | Biconnected components demo |
-r | --resilience | Resilience comparison |
-f | --fix | Fixing vulnerabilities by adding edges |
-d | --bridges | Bridge edges demo |
-a | --all | Run all demos (default if no flag given) |
Definition in file cut_nodes_example.C.
Definition at line 107 of file cut_nodes_example.C.
| using Graph = List_Graph<Node, Arc> |
Definition at line 108 of file cut_nodes_example.C.
| using Node = Graph_Node<string> |
Definition at line 106 of file cut_nodes_example.C.
| Graph build_computer_network | ( | ) |
Build a graph representing a computer network.
Server1 — Router1 — Switch1 — PC1 | | | Switch2 — PC2 | | Router2 — Switch3 — PC3 | Server2
Definition at line 201 of file cut_nodes_example.C.
References Aleph::divide_and_conquer_partition_dp(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), and Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node().
Referenced by demo_bridges(), and demo_network_vulnerability().
| Graph build_cyclic_graph | ( | ) |
Build a cyclic graph with fewer cut nodes.
A --- B
/| |\ / | | \ E | | C \ | | / | |/ D — F — G
Only F is a cut node (the cycle A-B-C-F-D-E makes others resilient)
Definition at line 160 of file cut_nodes_example.C.
References Aleph::divide_and_conquer_partition_dp(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), and Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node().
Referenced by demo_resilience_comparison().
| Graph build_network_graph | ( | ) |
Build a network with clear cut nodes.
A --- B --- C
| |
D --- E --- F --- G
| |
+--H--+
Cut nodes: B, E, F (removing any disconnects the graph)
Definition at line 121 of file cut_nodes_example.C.
References Aleph::divide_and_conquer_partition_dp(), h, Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), and Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node().
Referenced by demo_biconnected_components(), demo_fixing_vulnerabilities(), demo_resilience_comparison(), and main().
| void demo_biconnected_components | ( | ) |
Demonstrate biconnected components.
Definition at line 354 of file cut_nodes_example.C.
References build_network_graph(), Aleph::color(), Aleph::divide_and_conquer_partition_dp(), GraphCommon< GT, Node, Arc >::get_counter(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::get_first_node(), LocateFunctions< Container, Type >::get_it(), GraphCommon< GT, Node, Arc >::get_node_it(), Aleph::Compute_Cut_Nodes< GT, SA >::paint_subgraphs(), and print_graph().
Referenced by main().
| void demo_bridges | ( | ) |
Demonstrate bridge finding with Compute_Bridges / find_bridges().
Shows three scenarios:
Definition at line 457 of file cut_nodes_example.C.
References build_computer_network(), Aleph::compute_cut_nodes(), Aleph::divide_and_conquer_partition_dp(), Aleph::find_bridges(), GraphCommon< GT, Node, Arc >::get_src_node(), GraphCommon< GT, Node, Arc >::get_tgt_node(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), and print_graph().
Referenced by main().
| void demo_cut_nodes | ( | Graph & | g, |
| const string & | description | ||
| ) |
Demonstrate finding cut nodes.
Definition at line 272 of file cut_nodes_example.C.
References Aleph::divide_and_conquer_partition_dp(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::get_first_node(), LocateFunctions< Container, Type >::get_it(), Aleph::Dlink::is_empty(), and Aleph::DynDlist< T >::size().
Referenced by main().
| void demo_fixing_vulnerabilities | ( | ) |
Demonstrate fixing network vulnerabilities.
Definition at line 550 of file cut_nodes_example.C.
References build_network_graph(), Aleph::divide_and_conquer_partition_dp(), find_node(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::get_first_node(), LocateFunctions< Container, Type >::get_it(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), and Aleph::Dlink::is_empty().
Referenced by main().
| void demo_network_vulnerability | ( | ) |
Practical example: Network vulnerability analysis.
Definition at line 307 of file cut_nodes_example.C.
References build_computer_network(), Aleph::divide_and_conquer_partition_dp(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::get_first_node(), LocateFunctions< Container, Type >::get_it(), Aleph::Dlink::is_empty(), Aleph::Filter_Iterator< Container, It, Show_Item >::next(), and print_graph().
Referenced by main().
| void demo_resilience_comparison | ( | ) |
Compare resilient vs fragile networks.
Definition at line 406 of file cut_nodes_example.C.
References build_cyclic_graph(), build_network_graph(), Aleph::divide_and_conquer_partition_dp(), print_graph(), and Aleph::DynDlist< T >::size().
Referenced by main().
| Graph::Node * find_node | ( | Graph & | g, |
| const string & | name | ||
| ) |
Find a node by name.
Definition at line 233 of file cut_nodes_example.C.
References GraphCommon< GT, Node, Arc >::get_node_it().
Referenced by demo_fixing_vulnerabilities().
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 608 of file cut_nodes_example.C.
References Aleph::and, build_network_graph(), cmd, demo_biconnected_components(), demo_bridges(), demo_cut_nodes(), demo_fixing_vulnerabilities(), demo_network_vulnerability(), demo_resilience_comparison(), Aleph::divide_and_conquer_partition_dp(), and print_graph().
| void print_graph | ( | Graph & | g, |
| const string & | title | ||
| ) |
Print graph structure.
Definition at line 244 of file cut_nodes_example.C.
References Aleph::divide_and_conquer_partition_dp(), GraphCommon< GT, Node, Arc >::get_connected_node(), GraphCommon< GT, Node, Arc >::get_node_it(), GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::get_num_nodes(), and Aleph::Filter_Iterator< Container, It, Show_Item >::next().
Referenced by demo_biconnected_components(), demo_bridges(), demo_network_vulnerability(), demo_resilience_comparison(), and main().