network

centrality

Description

The centrality action calculates various centrality metrics to identify the most important nodes in a network. These metrics measure a node's influence or importance based on its position within the graph structure. Key metrics include degree (number of connections), betweenness (role as a bridge), closeness (proximity to other nodes), and eigenvector-based measures like PageRank.

network.centrality <result=results> <status=rc> / auth="BOTH" | "UNWEIGHT" | "WEIGHT", between="BOTH" | "UNWEIGHT" | "WEIGHT", betweenNorm=TRUE | FALSE, close="BOTH" | "UNWEIGHT" | "WEIGHT", closeNoPath="DIAMETER" | "HARMONIC" | "NNODES" | "ZERO", clusteringCoefficient=TRUE | FALSE, degree="BOTH" | "UNWEIGHT" | "WEIGHT", deterministic=TRUE | FALSE, direction="DIRECTED" | "UNDIRECTED", display={...}, distributed=TRUE | FALSE, eigen="BOTH" | "UNWEIGHT" | "WEIGHT", eigenAlgorithm="AUTOMATIC" | "JACOBIDAVIDSON" | "POWER", eigenMaxIters=integer, graph=integer, hub="BOTH" | "UNWEIGHT" | "WEIGHT", indexOffset=integer, influence="BOTH" | "UNWEIGHT" | "WEIGHT", links={...}, linksVar={...}, logFreqTime=integer, logLevel="AGGRESSIVE" | "BASIC" | "MODERATE" | "NONE", multiLinks=TRUE | FALSE, nodes={...}, nodesVar={...}, nThreads=integer, outGraphList={...}, outLinks={...}, outNodes={...}, outputTables={...}, pageRank="BOTH" | "UNWEIGHT" | "WEIGHT", pageRankAlpha=double, pageRankTolerance=double, samplePercent=double, selfLinks=TRUE | FALSE, standardizedLabels=TRUE | FALSE, standardizedLabelsOut=TRUE | FALSE;
Settings
ParameterDescription
auth Specifies how to calculate authority centrality.
between Specifies how to calculate betweenness centrality.
betweenNorm When set to True, normalizes the betweenness centrality calculation.
close Specifies how to calculate closeness centrality.
closeNoPath Specifies a method of accounting for the shortest path distance between two nodes when a path does not exist.
clusteringCoefficient When set to True, calculates the node clustering coefficient.
degree Specifies how to calculate degree centrality.
deterministic When set to True, ensures that each invocation produces the same final result.
direction Specifies whether to consider the input graph as directed or undirected.
display Specifies a list of results tables to send to the client for display.
distributed When set to True, uses a distributed graph.
eigen Specifies how to calculate eigenvector centrality.
eigenAlgorithm Specifies the algorithm to use in calculating centrality metrics that require solving eigensystems.
eigenMaxIters Specifies the maximum number of iterations to use for eigenvector calculations.
graph Specifies the in-memory graph to use.
hub Specifies how to calculate hub centrality.
indexOffset Specifies the index offset for identifiers in the log and results output data tables.
influence Specifies how to calculate influence centrality.
links Specifies the input data table that contains the graph link information.
linksVar Specifies the data variable names for the links table.
logFreqTime Controls the frequency in seconds for displaying iteration logs.
logLevel Controls the amount of information that is displayed in the SAS log.
multiLinks When set to True, includes multilinks when an input graph is read.
nodes Specifies the input data table that contains the graph node information.
nodesVar Specifies the data variable names for the nodes table.
nThreads Specifies the maximum number of threads to use for multithreaded processing.
outGraphList Specifies the output data table to contain summary information about in-memory graphs.
outLinks Specifies the output data table to contain the graph link information along with any results from the algorithms that calculate metrics on links.
outNodes Specifies the output data table to contain the graph node information along with any results from the algorithms that calculate metrics on nodes.
outputTables Lists the names of results tables to save as CAS tables on the server.
pageRank Specifies how to calculate PageRank centrality.
pageRankAlpha Specifies the damping factor for the PageRank algorithm.
pageRankTolerance Specifies the convergence tolerance for the PageRank algorithm.
samplePercent Specifies the percentage of source nodes to sample for the approximate betweenness calculation.
selfLinks When set to True, includes self-links when an input graph is read.
standardizedLabels When set to True, specifies that the input graph data are in a standardized format.
standardizedLabelsOut When set to True, requests that the output graph data include standardized format.
Data Preparation View data prep sheet
Creating the Input Data

This example creates a simple social network graph to demonstrate how to calculate centrality metrics. The `mycas.Links` table defines the connections (links) between individuals (nodes), and the `mycas.Nodes` table defines the individuals themselves.

Copied!
1DATA mycas.Links;
2 INFILE DATALINES missover;
3 INPUT from $ to $ weight;
4 DATALINES;
5A B 1.0
6A C 1.0
7A D 1.0
8B C 2.0
9B E 1.0
10C D 1.0
11D E 1.0
12E F 1.0
13F G 1.0
14;
15RUN;
16 
17DATA mycas.Nodes;
18 INFILE DATALINES missover;
19 INPUT node $;
20 DATALINES;
21A
22B
23C
24D
25E
26F
27G
28;
29RUN;

Examples

This example calculates the unweighted degree centrality for each node in the graph. The results are stored in the `mycas.Centrality` output table.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 network.centrality /
3 links={name='Links'}
4 nodes={name='Nodes'}
5 degree='UNWEIGHT'
6 outNodes={name='Centrality', replace=true};
7RUN;
Result :
The `mycas.Centrality` table is created, containing the nodes of the graph and their corresponding unweighted degree centrality scores.

This example calculates several centrality metrics simultaneously: degree (weighted and unweighted), betweenness (weighted), and closeness (weighted). It demonstrates how to request multiple metrics in a single call. The results are saved to the `mycas.Centrality_Detailed` table.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 network.centrality /
3 links={name='Links'}
4 nodes={name='Nodes'}
5 degree='BOTH'
6 between='WEIGHT'
7 close='WEIGHT'
8 outNodes={name='Centrality_Detailed', replace=true};
9RUN;
Result :
The `mycas.Centrality_Detailed` table is created, containing columns for each requested centrality metric: `cent_degree_wt`, `cent_degree_unwt`, `cent_between_wt`, and `cent_close_wt`.

This example computes PageRank and Eigenvector centrality for a directed graph. The `direction` parameter is set to 'DIRECTED', and the results are output to the `mycas.NodeCentrality` table.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 network.centrality /
3 links={name='Links'}
4 direction='DIRECTED'
5 pageRank='WEIGHT'
6 eigen='WEIGHT'
7 outNodes={name='NodeCentrality', replace=true};
8RUN;
Result :
The `mycas.NodeCentrality` table is generated, which includes columns for PageRank (`cent_pagerank_wt`) and Eigenvector centrality (`cent_eigen_wt`) for each node.

Associated Scenarios

Use Case
Anti-Money Laundering: Identifying Mules and Hubs

A financial institution wants to detect potential money laundering rings. They need to identify 'Hub' accounts (high transaction volume/degree) and 'Bridge' accounts (high betwe...

Use Case
Telecommunications: Critical Infrastructure Analysis (High Volume)

A telecommunications company manages a massive network of towers and fiber connections. They need to identify the most critical nodes for network resilience. Since the graph is ...

Use Case
Social Media: Influence in Fragmented Directed Networks

A marketing agency is analyzing a social media platform with directed 'follows'. The network is fragmented (distinct communities that don't interact). They need to calculate Pag...