The Network Action Set

Example 16.1 Finding the Biconnected Components of a Simple Undirected Graph

Finding the Biconnected Components of a Simple Undirected Graph

This section contains PROC CAS code.

Note: Input data must be in a CAS table that is accessible in your CAS session. This table has a two-level name; the first level is your CAS engine libref and the second level is the table name. You refer to this table in the CAS procedure by specifying only the second level. For more information about two-level names, see Chapter 3: Shared Concepts in SAS Visual Data Mining and Machine Learning 8.3: Procedures Guide. For more information about PROC CAS and programming in CASL, see Getting Started with CASL, SAS Cloud Analytic Services: CAS Procedure Programming Guide and Reference, and SAS Viya: System Programming Guide.

This example illustrates the use of the biconnected components algorithm on the simple undirected graph G shown in Figure 16.1.

Figure 1: A Simple Undirected Graph G

A Simple Undirected Graph


The undirected graph G can be represented by the following links data set, LinkSetIn:

data LinkSetIn;
   input from $ to $ @@;
   datalines;
A B  A F  A G  B C  B D
B E  C D  E F  G I  G H
H I
;

The following DATA step loads the LinkSetIn data set into a CAS data table named mycas.LinkSetIn. These statements assume that the CAS engine libref is named mycas, but you can substitute any appropriately defined CAS engine libref.

data mycas.LinkSetIn;
   set LinkSetIn;
run;

The following statements calculate the biconnected components and articulation points for G and output the results in the data tables LinkSetOut and NodeSetOut:

proc cas;
   loadactionset "network";
   action network.biconnectedComponents result=r status=s /
      indexOffset = 1
      links       = {name = "LinkSetIn"}
      outNodes    = {name = "NodeSetOut", replace="true"}
      outLinks    = {name = "LinkSetOut", replace="true"};
   run;
   print r.ProblemSummary; run;
   print r.SolutionSummary; run;
   action table.fetch / table = "LinkSetOut" sortBy = "biconcomp"; run;
   action table.fetch / table = "NodeSetOut"; run;
quit;

The problem summary output from this action is presented in Output 16.1.1.

Output 16.1.1: Problem Summary

Problem Summary
Number of Nodes9
Number of Links11
Graph DirectionUndirected


The solution summary output from this action is presented in Output 16.1.2.

Output 16.1.2: Solution Summary

Solution Summary
Problem TypeBiconnected Components
Solution StatusOK
Number of Components4
Number of Articulation Points3
CPU Time0.00
Real Time0.00


The output data table LinkSetOut contains the biconnected components of the input graph, as shown in Output 16.1.3.

Output 16.1.3: Biconnected Components of a Simple Undirected Graph

Selected Rows from Table LINKSETOUT
_Index_fromtobiconcomp
1AF1
2AB1
3BE1
4EF1
5AG2
6CD3
7BC3
8BD3
9HI4
10GH4
11GI4


The output data table NodeSetOut contains the articulation points of the input graph, as shown in Output 16.1.4.

Output 16.1.4: Articulation Points of a Simple Undirected Graph

Selected Rows from Table NODESETOUT
_Index_nodeartpoint
1A1
2B1
3D0
4G1
5I0
6F0
7E0
8H0
9C0


The biconnected components are shown graphically in Output 16.1.5 and Output 16.1.6.

Output 16.1.5: Biconnected Components and

biconcomp1_2

biconcomp1_3


Output 16.1.6: Biconnected Components and

biconcomp1_1

biconcomp1_4


Finding the Biconnected Components of a Simple Undirected Graph

This section contains Lua code for the analysis in the CASL version of this example, which contains details about the results.

Note: In order to run this code, the data that are described in the CASL version need to be loaded into CAS. One way to do this is to convert the LinkSetIn data to the comma-separated-value (CSV) file LinkSetIn.csv and then use the following code to load the CSV file into CAS:

   s:loadtable{casLib="casuser", path="LinkSetIn.csv"}

For more information about coding in Lua, see Getting Started with SAS Viya for Lua and SAS Viya: System Programming Guide.

The following statements calculate the biconnected components and articulation points for G and output the results in the data tables LinkSetOut and NodeSetOut:

s:network_biconnectedComponents{
   indexOffset = 1,
   links       = {name = "LinkSetIn"},
   outNodes    = {name = "NodeSetOut", replace=true},
   outLinks    = {name = "LinkSetOut", replace=true}}

Finding the Biconnected Components of a Simple Undirected Graph

This section contains Python code for the analysis in the CASL version of this example, which contains details about the results.

Note: In order to run this code, the data that are described in the CASL version need to be loaded into CAS. One way to do this is to convert the LinkSetIn data to the comma-separated-value (CSV) file LinkSetIn.csv and then use the following code to load the CSV file into CAS:

   s.upload_file('LinkSetIn.csv')
  

For more information about coding in Python, see Getting Started with SAS Viya for Python and SAS Viya: System Programming Guide.

The following statements calculate the biconnected components and articulation points for G and output the results in the data tables LinkSetOut and NodeSetOut:

s.network.biconnectedComponents(
   indexOffset = 1,
   links       = {"name":"LinkSetIn"},
   outNodes    = {"name":"NodeSetOut", "replace":True},
   outLinks    = {"name":"LinkSetOut", "replace":True})

Finding the Biconnected Components of a Simple Undirected Graph

This example is not available for the R programming language.

Last updated: June 07, 2018