122#include <tclap/CmdLine.h>
125using namespace Aleph;
257 for (
auto it = g.
get_node_it(); it.has_curr(); it.next())
258 if (it.get_curr()->get_info() == name)
259 return it.get_curr();
275 auto* node =
nit.get_curr();
276 cout <<
" " << node->get_info() <<
" -- ";
281 auto* arc =
ait.get_curr();
296 cout <<
"\n--- Finding Cut Nodes (Articulation Points) ---" <<
endl;
306 cout <<
"\nNo cut nodes found - graph is biconnected!" <<
endl;
307 cout <<
"Removing any single node won't disconnect the graph." <<
endl;
311 cout <<
"\nCut nodes found: " << cut_nodes.
size() <<
endl;
312 cout <<
"Cut nodes: ";
314 for (
auto it = cut_nodes.
get_it(); it.has_curr(); it.next())
317 cout << it.get_curr()->get_info();
322 cout <<
"\nImpact: Removing any of these nodes disconnects the graph." <<
endl;
331 cout <<
"\n" << string(60,
'=') <<
endl;
332 cout <<
"Practical Example: Network Vulnerability Analysis" <<
endl;
343 cout <<
"\n--- Vulnerability Analysis ---" <<
endl;
347 cout <<
"Network is fully redundant - no single point of failure!" <<
endl;
351 cout <<
"Single points of failure identified:" <<
endl;
352 for (
auto it = cut_nodes.
get_it(); it.has_curr(); it.next())
354 auto* node = it.get_curr();
355 cout <<
"\n * " << node->get_info() <<
endl;
363 cout <<
" Risk: CRITICAL - failure would partition the network" <<
endl;
367 cout <<
"\n--- Recommendations ---" <<
endl;
368 cout <<
"1. Add redundant links to eliminate cut nodes" <<
endl;
369 cout <<
"2. Prioritize backup for critical equipment" <<
endl;
370 cout <<
"3. Monitor cut nodes for failures" <<
endl;
378 cout <<
"\n" << string(60,
'=') <<
endl;
379 cout <<
"Biconnected Components" <<
endl;
390 cout <<
"\nCut nodes: ";
391 for (
auto it = cut_nodes.
get_it(); it.has_curr(); it.next())
392 cout << it.get_curr()->get_info() <<
" ";
398 cout <<
"\n--- Biconnected Components ---" <<
endl;
401 cout <<
"\nNodes by component (color):" <<
endl;
408 auto* node =
nit.get_curr();
412 cout << node->get_info();
419 cout <<
"\n--- Analysis ---" <<
endl;
420 cout <<
"A biconnected component has no cut nodes within it." <<
endl;
421 cout <<
"Components are connected through cut nodes." <<
endl;
429 cout <<
"\n" << string(60,
'=') <<
endl;
430 cout <<
"Network Resilience Comparison" <<
endl;
434 cout <<
"\n--- Fragile Network (Tree-like) ---" <<
endl;
441 compute(
fragile.get_first_node(), cut_nodes);
443 cout <<
"Cut nodes: " << cut_nodes.
size() <<
" out of "
450 cout <<
"\n--- Resilient Network (With Cycles) ---" <<
endl;
457 compute(
resilient.get_first_node(), cut_nodes);
459 cout <<
"Cut nodes: " << cut_nodes.
size() <<
" out of "
465 cout <<
"\n--- Key Insight ---" <<
endl;
466 cout <<
"Adding redundant connections (creating cycles) reduces fragility" <<
endl;
467 cout <<
"by eliminating articulation points." <<
endl;
475 cout <<
"\n" << string(60,
'=') <<
endl;
476 cout <<
"Fixing Network Vulnerabilities" <<
endl;
481 cout <<
"\n--- Before: Original Network ---" <<
endl;
488 cout <<
"Cut nodes: ";
489 for (
auto it = cut_nodes.
get_it(); it.has_curr(); it.next())
490 cout << it.get_curr()->get_info() <<
" ";
494 cout <<
"\n--- Adding Redundant Links ---" <<
endl;
502 cout <<
"Adding link: C -- D" <<
endl;
505 cout <<
"Adding link: A -- F" <<
endl;
508 cout <<
"\n--- After: Reinforced Network ---" <<
endl;
516 cout <<
"No cut nodes! Network is now more resilient." <<
endl;
519 cout <<
"Remaining cut nodes: ";
520 for (
auto it = cut_nodes.
get_it(); it.has_curr(); it.next())
521 cout << it.get_curr()->get_info() <<
" ";
527 cout <<
"Strategic addition of edges can eliminate articulation points" <<
endl;
528 cout <<
"and improve network reliability." <<
endl;
535 TCLAP::CmdLine
cmd(
"Cut Nodes (Articulation Points) Example",
' ',
"1.0");
537 TCLAP::SwitchArg
basicArg(
"b",
"basic",
538 "Show basic cut nodes demo",
false);
539 TCLAP::SwitchArg
netArg(
"n",
"network",
540 "Show network vulnerability analysis",
false);
541 TCLAP::SwitchArg
biconArg(
"c",
"biconnected",
542 "Show biconnected components",
false);
543 TCLAP::SwitchArg
compareArg(
"r",
"resilience",
544 "Compare network resilience",
false);
545 TCLAP::SwitchArg
fixArg(
"f",
"fix",
546 "Show fixing vulnerabilities",
false);
547 TCLAP::SwitchArg
allArg(
"a",
"all",
548 "Run all demos",
false);
570 cout <<
"=== Cut Nodes (Articulation Points) and Biconnected Components ===" <<
endl;
571 cout <<
"A cut node's removal disconnects the graph." <<
endl;
592 cout <<
"\n=== Summary ===" <<
endl;
593 cout <<
"Cut nodes are critical points in network topology." <<
endl;
594 cout <<
"Uses: Network reliability, infrastructure planning, graph analysis" <<
endl;
595 cout <<
"Algorithm: DFS with low-link values, O(V + E)" <<
endl;
599 catch (TCLAP::ArgException& e)
601 cerr <<
"Error: " << e.error() <<
" for arg " << e.argId() <<
endl;
WeightedDigraph::Node Node
Computation of cut nodes (articulation points) of a graph.
long paint_subgraphs()
Paints the connected components around the cut nodes.
constexpr bool is_empty() const noexcept
Return true if this (as header node) is empty.
Dynamic doubly linked list with O(1) size and bidirectional access.
const size_t & size() const noexcept
Return the number of elements (constant time)
Node * get_first_node() const
Return any node in the graph.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
Node * get_connected_node(Arc *arc, Node *node) const noexcept
Return the adjacent node to node through arc.
long & get_counter(Node *node) const noexcept
Get a modifiable reference to the counter of node
constexpr size_t get_num_arcs() const noexcept
auto get_node_it() const noexcept
Obtains an iterator to the nodes of graph.
auto get_it() const
Return a properly initialized iterator positioned at the first item on the container.
Graph build_computer_network()
Build a graph representing a computer network.
Graph build_network_graph()
Build a network with clear cut nodes.
void demo_biconnected_components()
Demonstrate biconnected components.
void print_graph(Graph &g, const string &title)
Print graph structure.
Graph build_cyclic_graph()
Build a cyclic graph with fewer cut nodes.
void demo_fixing_vulnerabilities()
Demonstrate fixing network vulnerabilities.
void demo_network_vulnerability()
Practical example: Network vulnerability analysis.
void demo_resilience_comparison()
Compare resilient vs fragile networks.
Graph::Node * find_node(Graph &g, const string &name)
Find a node by name.
void demo_cut_nodes(Graph &g, const string &description)
Demonstrate finding cut nodes.
Main namespace for Aleph-w library functions.
static long & color(typename GT::Node *p)
DynList< T > maps(const C &c, Op op)
Classic map operation.
Arc of graph implemented with double-linked adjacency lists.
Node belonging to a graph implemented with a double linked adjacency list.
Filtered iterator of adjacent arcs of a node.
Articulation points (cut nodes) and bridges.
Generic graph and digraph implementations.