optNetwork connectedComponents

Supply Chain Resilience (Directed Graph & Edge Cases)

Scénario de test & Cas d'usage

Business Context

A logistics company is mapping its supply chain to find broken links or isolated subnetworks. They need to treat the graph as DIRECTED (Factory -> Warehouse) and must handle 'dirty' data such as self-shipping (loops) or single-point anomalies.
About the Set : optNetwork

Network analysis and graph algorithms.

Discover all actions of optNetwork
Data Preparation

Creation of a supply chain graph including self-links (Warehouse A shipping to Warehouse A) and disjointed paths.

Copied!
1 
2DATA mycas.logistics;
3INPUT
4SOURCE $ dest $ distance;
5DATALINES;
6FACT_1 WARE_A 100 WARE_A STORE_1 50 STORE_1 STORE_1 0 FACT_2 FACT_2 0 FACT_3 WARE_B 200 ;
7 
8RUN;
9 

Étapes de réalisation

1
Execute connectedComponents forcing a DIRECTED graph interpretation and allowing self-links.
Copied!
1 
2PROC CAS;
3optNetwork.connectedComponents links={name='logistics', vars={from='
4source', to='dest'}} direction='DIRECTED' selfLinks=true outNodes={name='network_integrity', replace=true} out={name='integrity_summary', replace=true};
5 
6RUN;
7 
2
Validation of the output to ensure self-links were processed.
Copied!
1 
2PROC CAS;
3TABLE.fetch TABLE={name='network_integrity', where='node in ("STORE_1", "FACT_2")'};
4 
5RUN;
6 

Expected Result


The action should successfully process the graph as directed. Nodes with self-links (STORE_1, FACT_2) should be included in the results and assigned valid component IDs, proving that `selfLinks=true` functioned correctly. The result distinguishes between the weakly connected sub-graphs.