NETWORK Procedure

Centrality

In general terms, the centrality of a node or link in a graph gives some indication of its relative importance within the graph. In the field of network analysis, many different types of centrality metrics are used to better understand levels of prominence. For a good review of centrality metrics, see Newman (2010).

You can use the CENTRALITY statement in PROC NETWORK to calculate several of these metrics. The options for this statement are described in the section CENTRALITY Statement.

Let upper G equals left-parenthesis upper N comma upper E right-parenthesis define a graph that contains nodes N and links E. The following sections describe each of the possible centrality metrics that you can calculate in PROC NETWORK.

Degree Centrality

The (unweighted) degree (valency) of a node j in an undirected graph is the number of links that are incident to node j, with self-links counted twice. The out-degree of a node in a directed graph is the number of out-links incident to that node; the in-degree is the number of in-links incident to that node. For an undirected graph, the terms degree and out-degree are interchangeable. Degree centrality is simply the in- or out-degree of a node and can be interpreted as some form of the node’s relative importance to a network. For example, in a network where nodes are people and you are tracking the flow of a virus, the degree centrality gives some idea of the magnitude of the risk of spreading the virus. People who have a higher out-degree can lead to faster and more widespread transmission. In a friendship network, in-degree often indicates popularity.

The weighted degree of a node is a generalization of degree; it is the sum of the link weights incident to that node. For unweighted graphs, the default weight of each link is 1.

For undirected graphs, degree centrality is

StartLayout 1st Row 1st Column upper C Subscript d Baseline left-parenthesis i right-parenthesis 2nd Column equals 3rd Column sigma-summation Underscript e element-of delta Subscript i Endscripts w Subscript e Superscript upper E EndLayout

where delta Subscript i represents the set of links that are incident to node i, and w Subscript e Superscript upper E is the weight of link e.

For directed graphs, out-degree centrality of node i is

StartLayout 1st Row 1st Column upper C Subscript d Superscript normal o normal u normal t Baseline left-parenthesis i right-parenthesis 2nd Column equals 3rd Column sigma-summation Underscript e element-of delta Subscript i Superscript normal o normal u normal t Endscripts w Subscript e Superscript upper E EndLayout

where delta Subscript i Superscript normal o normal u normal t represents the set of outgoing links that are connected from node i.

For directed graphs, in-degree centrality of node i is

StartLayout 1st Row 1st Column upper C Subscript d Superscript normal i normal n Baseline left-parenthesis i right-parenthesis 2nd Column equals 3rd Column sigma-summation Underscript e element-of delta Subscript i Superscript normal i normal n Endscripts w Subscript e Superscript upper E EndLayout

where delta Subscript i Superscript normal i normal n represents the set of incoming links that are connected to node i.

The overall degree centrality for a directed graph is calculated as

StartLayout 1st Row 1st Column upper C Subscript d Baseline left-parenthesis i right-parenthesis 2nd Column equals 3rd Column upper C Subscript d Superscript normal o normal u normal t Baseline left-parenthesis i right-parenthesis plus upper C Subscript d Superscript normal i normal n Baseline left-parenthesis i right-parenthesis EndLayout

Degree centrality is calculated using the value of the DEGREE= option in the CENTRALITY statement. To specify a distributed graph algorithm, you can set DISTRIBUTED=TRUE in the PROC NETWORK statement.

The algorithm that PROC NETWORK uses to compute degree centrality runs in time upper O left-parenthesis StartAbsoluteValue upper N EndAbsoluteValue right-parenthesis, and therefore should scale to very large graphs.

OUTNODES= Data Table

The results are provided in the nodes output data table that you specify in the OUTNODES= option in the PROC NETWORK statement.

The OUTNODES= data table contains the degree centrality of each node. This data table contains the following column:

  • node: the node label

If the graph is undirected and you specify DEGREE=UNWEIGHT or DEGREE=BOTH, the following column also appears in the nodes output data table:

  • centr_degree_out: the unweighted degree centrality of the node

If the graph is undirected and you specify DEGREE=WEIGHT or DEGREE=BOTH, the following column also appears in the nodes output data table:

  • centr_degree_out_wt: the weighted degree centrality of the node

If the graph is directed and you specify DEGREE=UNWEIGHT or DEGREE=BOTH, the following columns also appear in the nodes output data table:

  • centr_degree_in: the unweighted in-degree centrality of the node

  • centr_degree_out: the unweighted out-degree centrality of the node

  • centr_degree: the sum of the unweighted in- and out-degree centrality of the node

If the graph is directed and you specify DEGREE=WEIGHT or DEGREE=BOTH, the following columns also appear in the nodes output data table:

  • centr_degree_in_wt: the weighted in-degree centrality of the node

  • centr_degree_out_wt: the weighted out-degree centrality of the node

  • centr_degree_wt: the sum of the weighted in- and out-degree centrality of the node

Degree Centrality of a Directed Graph

As a simple example, consider again the directed graph in Figure 7 with the data table mylib.LinkSetIn, which is defined in the section Links Input Data. The following statements calculate the weighted degree centrality for both in- and out-degrees:

proc network
   direction  = directed
   links      = mylib.LinkSetIn
   outNodes   = mylib.NodeSetOut;
   centrality
      degree  = weight;
run;

The nodes data table mylib.NodeSetOut now contains the degree centrality for each node of the input graph. This data table is shown in Figure 56.

Figure 56: Degree Centrality of a Directed Graph

nodecentr_degree_in_wtcentr_degree_out_wtcentr_degree_wt
F7613
G8210
B189
A077
E437
D516
H156
C314
I404


Influence Centrality

Influence centrality is a generalization of degree centrality that considers the link and node weights of adjacent nodes (upper C 1) in addition to the link weights of nodes that are adjacent to adjacent nodes (upper C 2). The metric upper C 1 is referred to as first-order influence centrality, and the metric upper C 2 is referred to as second-order influence centrality.

For undirected graphs, influence centrality is

StartLayout 1st Row 1st Column upper C 1 left-parenthesis i right-parenthesis 2nd Column equals 3rd Column StartFraction sigma-summation Underscript e element-of delta Subscript i Baseline Endscripts w Subscript e Superscript upper E Baseline Over sigma-summation Underscript j element-of upper N Endscripts w Subscript j Superscript upper N Baseline EndFraction 2nd Row 1st Column upper C 2 left-parenthesis i right-parenthesis 2nd Column equals 3rd Column sigma-summation Underscript j element-of upper N overbar Subscript i Endscripts upper C 1 left-parenthesis j right-parenthesis EndLayout

where delta Subscript i represents the set of links that are incident to node i, upper N overbar Subscript i represents the multiset of neighbors (that is, nodes that are connected by links incident with node i), w Subscript e Superscript upper E is the weight of link e, and w Subscript i Superscript upper N is the weight of node i.

For directed graphs, influence centrality is

StartLayout 1st Row 1st Column upper C 1 left-parenthesis i right-parenthesis 2nd Column equals 3rd Column StartFraction sigma-summation Underscript e element-of delta Subscript i Superscript normal o normal u normal t Baseline Endscripts w Subscript e Superscript upper E Baseline Over sigma-summation Underscript j element-of upper N Endscripts w Subscript j Superscript upper N Baseline EndFraction 2nd Row 1st Column upper C 2 left-parenthesis i right-parenthesis 2nd Column equals 3rd Column sigma-summation Underscript j element-of upper N overbar Subscript i Superscript normal o normal u normal t Endscripts upper C 1 left-parenthesis j right-parenthesis EndLayout

where delta Subscript i Superscript normal o normal u normal t represents the set of outgoing links that are connected from node i and upper N overbar Subscript i Superscript normal o normal u normal t represents the multiset of out-neighbors (that is, nodes that are connected by outgoing links from node i).

As the name suggests, this metric indicates potential influence, performance, or ability to transfer knowledge. Influence centrality is calculated using the value of the INFLUENCE= option in the CENTRALITY statement.

The algorithm that PROC NETWORK uses to compute influence centrality is a simple traversal, runs in time upper O left-parenthesis StartAbsoluteValue upper E EndAbsoluteValue right-parenthesis, and therefore should scale to very large graphs.

OUTNODES= Data Table

The results are provided in the nodes output data table that you specify in the OUTNODES= option in the PROC NETWORK statement.

The OUTNODES= data table contains the influence centrality of each node. This data table contains the following column:

  • node: the node label

If you specify INFLUENCE=UNWEIGHT or INFLUENCE=BOTH, the following columns also appear in the nodes output data table:

  • centr_influence1_unwt: the unweighted first-order influence centrality of the node

  • centr_influence2_unwt: the unweighted second-order influence centrality of the node

If you specify INFLUENCE=WEIGHT or INFLUENCE=BOTH, the following columns also appear in the nodes output data table:

  • centr_influence1_wt: the weighted first-order influence centrality of the node

  • centr_influence2_wt: the weighted second-order influence centrality of the node

Influence Centrality of a Directed Graph

Consider again the directed graph in Figure 7. Ignore the weights and just calculate the upper C 1 and upper C 2 metrics that are based on connections (that is, consider all link and node weights as 1). The following statements calculate the unweighted influence centrality:

proc network
   direction    = directed
   links        = mylib.LinkSetIn
   outNodes     = mylib.NodeSetOut;
   centrality
      influence = unweight;
run;

The nodes data table mylib.NodeSetOut now contains the unweighted influence centrality for each node of the input graph. This data table is shown in Figure 57.

Figure 57: Influence Centrality of a Directed Graph

nodecentr_influence1_unwtcentr_influence2_unwt
A0.333330.55556
B0.333330.44444
E0.222220.22222
G0.222220.22222
H0.222220.22222
C0.111110.22222
D0.111110.22222
F0.111110.22222
I0.000000.00000


For a more detailed example, see Example 2.2: Influence Centrality for Project Groups in a Research Department.

Clustering Coefficient

The local clustering coefficient of a node is the number of links between the nodes within its neighborhood divided by the number of links that could possibly exist between them (their induced complete graph). The local clustering coefficient metric is often referred to as transitivity.

The formula for the clustering coefficient is

upper C left-parenthesis i right-parenthesis equals StartFraction sigma-summation Underscript StartLayout 1st Row  j element-of ModifyingAbove upper N With caret Subscript i Baseline comma k element-of ModifyingAbove upper N With caret Subscript i Baseline colon 2nd Row  j less-than k EndLayout Endscripts b Subscript j k Baseline Over upper K left-parenthesis ModifyingAbove upper N With caret Subscript i Baseline right-parenthesis EndFraction

when DIRECTION=UNDIRECTED, or

upper C left-parenthesis i right-parenthesis equals StartFraction sigma-summation Underscript StartLayout 1st Row  j element-of ModifyingAbove upper N With caret Subscript i Superscript normal o normal u normal t Baseline comma k element-of ModifyingAbove upper N With caret Subscript i Superscript normal o normal u normal t Baseline colon 2nd Row  j not-equals k EndLayout Endscripts b Subscript j k Baseline Over upper K left-parenthesis ModifyingAbove upper N With caret Subscript i Superscript normal o normal u normal t Baseline right-parenthesis EndFraction

when DIRECTION=DIRECTED, where ModifyingAbove upper N With caret Subscript i represents the set of neighbors, excluding node i itself (that is, unique nodes that are connected by links, excluding self-links, incident with node i); ModifyingAbove upper N With caret Subscript i Superscript normal o normal u normal t represents the set of out-neighbors, excluding node i itself (that is, unique nodes that are connected by outgoing links, excluding self-links, from node i); and b Subscript j k specifies whether or not (1 or 0, respectively) a link from node j to node k exists in the link set E, as follows:

b Subscript j k Baseline equals StartLayout Enlarged left-brace 1st Row 1st Column 1 comma 2nd Column if there exists e element-of upper E such that normal f normal r normal o normal m left-parenthesis e right-parenthesis equals j and normal t normal o left-parenthesis e right-parenthesis equals k 2nd Row 1st Column 0 comma 2nd Column otherwise EndLayout

The definition of the local clustering coefficient for undirected graphs is closely related to the global triangle count, which is given by

upper C Subscript normal upper T Baseline equals one-third sigma-summation Underscript i element-of upper N Endscripts upper K left-parenthesis ModifyingAbove upper N With caret Subscript i Baseline right-parenthesis upper C left-parenthesis i right-parenthesis equals sigma-summation Underscript StartLayout 1st Row  i element-of upper N comma j element-of ModifyingAbove upper N With caret Subscript i Baseline comma k element-of ModifyingAbove upper N With caret Subscript i Baseline colon 2nd Row  i less-than j less-than k EndLayout Endscripts b Subscript j k

When DIRECTION=UNDIRECTED, this count is reported in the NUM_TRIANGLES term of the macro variable _NETWORK_.

In PROC NETWORK, the calculation of local clustering coefficient considers only binary networks. Weights and multilinks are ignored in the metric.

For a particular node, the clustering coefficient determines how close the subgraph that is induced by its neighbor set is to being a complete subgraph. In social networks, a high clustering coefficient can help predict relationships that might not be known, confirmed, or realized yet. Consider a social network of four people, where person A knows persons B, C, and D, person B knows person C, and person C knows person D. This does not guarantee that person B knows person D, but it is more likely that person B knows person D than that person B knows some random person.

The clustering coefficient is calculated when you specify the CLUSTERINGCOEFFICIENT option in the CENTRALITY statement.

The algorithm that PROC NETWORK uses to compute the clustering coefficient runs in time upper O left-parenthesis StartAbsoluteValue upper N EndAbsoluteValue cubed right-parenthesis. Therefore, this algorithm is not expected to scale to very large graphs.

OUTNODES= Data Table

The results are provided in the nodes output data table that you specify in the OUTNODES= option in the PROC NETWORK statement.

The OUTNODES= data table contains the clustering coefficient of each node. This data table contains the following columns:

  • node: the node label

  • centr_cluster: the clustering coefficient of the node

Clustering Coefficient of an Undirected Graph

Consider the three undirected graphs on four nodes shown in Figure Three Undirected Graphs.

Figure 58: Three Undirected Graphs

Graph 1 Graph 2 Graph 3
cluster1 cluster2 cluster3


Define the three links data tables as follows:

data mylib.LinkSetInCC1;
   input from $ to $ @@;
   datalines;
A B  A C  A D
B C  B D  C D
;

data mylib.LinkSetInCC2;
   input from $ to $ @@;
   datalines;
A B  A C  A D
C D
;

data mylib.LinkSetInCC3;
   input from $ to $ @@;
   datalines;
A B  A C  A D
;

The following statements use three calls to PROC NETWORK to calculate the clustering coefficients of each graph:

proc network
   links     = mylib.LinkSetInCC1
   outNodes  = mylib.NodeSetOut1;
   centrality
      clusteringCoef;
run;

proc network
   links     = mylib.LinkSetInCC2
   outNodes  = mylib.NodeSetOut2;
   centrality
      clusteringCoef;
run;

proc network
   links     = mylib.LinkSetInCC3
   outNodes  = mylib.NodeSetOut3;
   centrality
      clusteringCoef;
run;

The nodes data tables provide the clustering coefficients for each node of each input graph, as shown in Figure 59 through Figure 61.

Figure 59: Clustering Coefficient of an Undirected Graph 1

nodecentr_cluster
A1
B1
C1
D1


Figure 60: Clustering Coefficient of an Undirected Graph 2

nodecentr_cluster
C1.00000
D1.00000
A0.33333
B0.00000


Figure 61: Clustering Coefficient of an Undirected Graph 3

nodecentr_cluster
A0
B0
C0
D0


Closeness Centrality

Closeness centrality is the reciprocal of the average of the shortest path (geodesic) distances from a particular node to all other nodes. Closeness can be thought of as a measure of how long it takes information to spread from a particular node to other nodes in the network. The higher the closeness value of a particular node, the faster the information will spread from that node to other nodes.

Define d Subscript i j to be the shortest path distance from node i to node j, with link weight defined by the AUXWEIGHT= option in the LINKSVAR statement. If the auxiliary link weight is not specified, then the link weight defaults to 1 slash w, where w represents the weight assigned by the WEIGHT= option in the LINKSVAR statement. By default, this means that a higher link weight implies a stronger relationship between its nodes (similar to other centrality metrics).

Closeness Centrality for an Undirected Graph

For an undirected graph, upper R left-parenthesis i right-parenthesis equals StartSet j element-of upper N colon d Subscript i j Baseline less-than normal infinity EndSet is the set of reachable nodes from node i. The set of unreachable nodes from node i is upper N minus upper R left-parenthesis i right-parenthesis equals StartSet j element-of upper N colon d Subscript i j Baseline equals normal infinity EndSet. The CLOSENOPATH= option specifies how to handle unreachable nodes.

For the special case in which all nodes are unreachable from node i, the closeness centrality is defined as 0. Otherwise, closeness centrality is calculated as

upper C Subscript c Baseline left-parenthesis i right-parenthesis equals s left-parenthesis i right-parenthesis left-parenthesis StartFraction n left-parenthesis i right-parenthesis Over sigma-summation Underscript j element-of upper R left-parenthesis i right-parenthesis Endscripts d Subscript i j Baseline plus StartAbsoluteValue upper N minus upper R left-parenthesis i right-parenthesis EndAbsoluteValue p EndFraction right-parenthesis

where p defines a penalty parameter for unreachable nodes, n left-parenthesis i right-parenthesis defines the number of nodes that are considered in calculating the average, and s left-parenthesis i right-parenthesis is a scaling factor, as shown in Table 11.

Table 11: Formulas for CLOSENOPATH= Option for Undirected Graphs

CLOSENOPATH= p n left-parenthesis i right-parenthesis s left-parenthesis i right-parenthesis
DIAMETER max Underscript left-parenthesis i comma j right-parenthesis element-of upper N times upper N Endscripts left-brace d Subscript i j Baseline colon d Subscript i j Baseline less-than normal infinity right-brace plus 1 StartAbsoluteValue upper N EndAbsoluteValue minus 1 1
NNODES StartAbsoluteValue upper N EndAbsoluteValue StartAbsoluteValue upper N EndAbsoluteValue minus 1 1
ZERO 0 StartAbsoluteValue upper R left-parenthesis i right-parenthesis EndAbsoluteValue minus 1 StartFraction StartAbsoluteValue upper R left-parenthesis i right-parenthesis EndAbsoluteValue minus 1 Over StartAbsoluteValue upper N EndAbsoluteValue minus 1 EndFraction


Closeness Centrality for a Directed Graph

For a directed graph, upper R Superscript normal o normal u normal t Baseline left-parenthesis i right-parenthesis equals StartSet j element-of upper N colon d Subscript i j Baseline less-than normal infinity EndSet is the set of reachable nodes from node i, whereas upper R Superscript normal i normal n Baseline left-parenthesis i right-parenthesis equals StartSet j element-of upper N colon d Subscript j i Baseline less-than normal infinity EndSet is the set of nodes from which there is a finite path to node i. The set of unreachable nodes from node i is upper N minus upper R Superscript normal o normal u normal t Baseline left-parenthesis i right-parenthesis equals StartSet j element-of upper N colon d Subscript i j Baseline equals normal infinity EndSet, whereas the set of nodes from which there is no finite path to node i is upper N minus upper R Superscript normal i normal n Baseline left-parenthesis i right-parenthesis equals StartSet j element-of upper N colon d Subscript j i Baseline equals normal infinity EndSet.

For the special case in which all nodes are unreachable from node i, the out-closeness centrality is defined as 0. Otherwise, out-closeness centrality is calculated as

upper C Subscript c Superscript normal o normal u normal t Baseline left-parenthesis i right-parenthesis equals s Superscript normal o normal u normal t Baseline left-parenthesis i right-parenthesis left-parenthesis StartFraction n Superscript normal o normal u normal t Baseline left-parenthesis i right-parenthesis Over sigma-summation Underscript j element-of upper R Superscript normal o normal u normal t Baseline left-parenthesis i right-parenthesis Endscripts d Subscript i j Baseline plus StartAbsoluteValue upper N minus upper R Superscript normal o normal u normal t Baseline left-parenthesis i right-parenthesis EndAbsoluteValue p EndFraction right-parenthesis

where n Superscript normal o normal u normal t Baseline left-parenthesis i right-parenthesis defines the number of nodes that are considered in calculating the average and s Superscript normal o normal u normal t Baseline left-parenthesis i right-parenthesis is a scaling factor, as shown in Table 12.

For the special case in which node i is unreachable from all the other nodes, the in-closeness centrality is defined as 0. Otherwise, in-closeness centrality is calculated as

upper C Subscript c Superscript normal i normal n Baseline left-parenthesis i right-parenthesis equals s Superscript normal i normal n Baseline left-parenthesis i right-parenthesis left-parenthesis StartFraction n Superscript normal i normal n Baseline left-parenthesis i right-parenthesis Over sigma-summation Underscript j element-of upper R Superscript normal i normal n Baseline left-parenthesis i right-parenthesis Endscripts d Subscript j i Baseline plus StartAbsoluteValue upper N minus upper R Superscript normal i normal n Baseline left-parenthesis i right-parenthesis EndAbsoluteValue p EndFraction right-parenthesis

where n Superscript normal i normal n Baseline left-parenthesis i right-parenthesis defines the number of nodes that are considered in calculating the average and s Superscript normal i normal n Baseline left-parenthesis i right-parenthesis is a scaling factor, as shown in Table 12.

Table 12: Formulas for CLOSENOPATH= Option for Directed Graphs

CLOSENOPATH= n Superscript normal o normal u normal t Baseline left-parenthesis i right-parenthesis s Superscript normal o normal u normal t Baseline left-parenthesis i right-parenthesis n Superscript normal i normal n Baseline left-parenthesis i right-parenthesis s Superscript normal i normal n Baseline left-parenthesis i right-parenthesis
DIAMETER StartAbsoluteValue upper N EndAbsoluteValue minus 1 1 StartAbsoluteValue upper N EndAbsoluteValue minus 1 1
NNODES StartAbsoluteValue upper N EndAbsoluteValue minus 1 1 StartAbsoluteValue upper N EndAbsoluteValue minus 1 1
ZERO StartAbsoluteValue upper R Superscript normal o normal u normal t Baseline left-parenthesis i right-parenthesis EndAbsoluteValue minus 1 StartFraction StartAbsoluteValue upper R Superscript normal o normal u normal t Baseline left-parenthesis i right-parenthesis EndAbsoluteValue minus 1 Over StartAbsoluteValue upper N EndAbsoluteValue minus 1 EndFraction StartAbsoluteValue upper R Superscript normal i normal n Baseline left-parenthesis i right-parenthesis EndAbsoluteValue minus 1 StartFraction StartAbsoluteValue upper R Superscript normal i normal n Baseline left-parenthesis i right-parenthesis EndAbsoluteValue minus 1 Over StartAbsoluteValue upper N EndAbsoluteValue minus 1 EndFraction


The overall closeness centrality for directed graphs is calculated as

upper C Subscript c Baseline left-parenthesis i right-parenthesis equals StartFraction upper C Subscript c Superscript normal o normal u normal t Baseline left-parenthesis i right-parenthesis plus upper C Subscript c Superscript normal i normal n Baseline left-parenthesis i right-parenthesis Over 2 EndFraction
Harmonic Centrality

Harmonic centrality, as described in Rochat (2009), is a variant of closeness centrality that attempts to simplify the treatment of unreachable nodes by calculating the average of the reciprocal of the shortest path distances from a particular node to all the other nodes. The formula for harmonic centrality is

upper C Subscript h Baseline left-parenthesis i right-parenthesis equals StartFraction 1 Over StartAbsoluteValue upper N EndAbsoluteValue minus 1 EndFraction sigma-summation Underscript j element-of upper N minus StartSet i EndSet Endscripts StartFraction 1 Over d Subscript i j Baseline EndFraction

To enable the calculation of harmonic centrality, use the CLOSENOPATH=HARMONIC option.

Closeness centrality is calculated using the value of the CLOSE= option in the CENTRALITY statement. If CLOSE=WEIGHT (or BOTH), then the shortest paths are calculated with respect to the weighted graph. Because the metric uses shortest paths to determine closeness, the weight and the closeness metric are inversely related. In general, the lower the weight, the higher the contribution to the closeness metric.

The algorithm that PROC NETWORK uses to compute closeness centrality relies on calculating shortest paths for all source-sink pairs and runs in time upper O left-parenthesis StartAbsoluteValue upper N EndAbsoluteValue times left-parenthesis StartAbsoluteValue upper N EndAbsoluteValue log StartAbsoluteValue upper N EndAbsoluteValue plus StartAbsoluteValue upper E EndAbsoluteValue right-parenthesis right-parenthesis. Therefore, this algorithm is not expected to scale to very large graphs. Because the shortest path calculations can be computed independently (for each source node), the algorithm uses multiple threads and multiple machines (depending on your session configuration and license).

OUTNODES= Data Table

The results are provided in the nodes output data table that you specify in the OUTNODES= option in the PROC NETWORK statement.

The OUTNODES= data table contains the closeness centrality of each node. This data table contains the following column:

  • node: the node label

If the graph is undirected and you specify CLOSE=UNWEIGHT or CLOSE=BOTH, the following column also appears in the nodes output data table:

  • centr_close_unwt: the unweighted closeness centrality of the node

If the graph is undirected and you specify CLOSE=WEIGHT or CLOSE=BOTH, the following column also appears in the nodes output data table:

  • centr_close_wt: the weighted closeness centrality of the node

If the graph is directed and you specify CLOSE=UNWEIGHT or CLOSE=BOTH, the following columns also appear in the nodes output data table:

  • centr_close_in_unwt: the unweighted in-closeness centrality of the node

  • centr_close_out_unwt: the unweighted out-closeness centrality of the node

  • centr_close_unwt: the unweighted closeness centrality of the node

If the graph is directed and you specify CLOSE=WEIGHT or CLOSE=BOTH, the following columns also appear in the nodes output data table:

  • centr_close_in_wt: the weighted in-closeness centrality of the node

  • centr_close_out_wt: the weighted out-closeness centrality of the node

  • centr_close_wt: the weighted closeness centrality of the node

Closeness Centrality of a Directed Graph

Consider again the directed graph in Figure 7 with the data table mylib.LinkSetIn, which is defined in the section Links Input Data. The following statements calculate the closeness centrality for both the weighted and unweighted graphs:

proc network
   direction  = directed
   links      = mylib.LinkSetIn
   outNodes   = mylib.NodeSetOut;
   centrality
      close   = both;
run;

The nodes data table mylib.NodeSetOut now contains the weighted and unweighted directed closeness centrality of the input graph. This data table is shown in Figure 62.

Figure 62: Closeness Centrality of a Directed Graph

nodecentr_close_wtcentr_close_in_wtcentr_close_out_wtcentr_close_unwtcentr_close_in_unwtcentr_close_out_unwt
G0.564020.794700.333330.325000.400000.25000
B0.551340.300000.802680.333330.222220.44444
E0.459620.434390.484850.320000.320000.32000
F0.443570.503140.384000.307250.347830.26667
H0.416630.482900.350360.278850.307690.25000
D0.401130.412020.390240.291780.307690.27586
A0.388350.000000.776700.222220.000000.44444
C0.382600.340430.424780.278850.250000.30769
I0.302270.604530.000000.181820.363640.00000


Betweenness Centrality

Betweenness centrality counts the number of times a particular node (or link) occurs in shortest paths between other nodes. Betweenness can be thought of as a measure of the control that a node (or link) has over the communication flow through the rest of the network. In this sense, the nodes (or links) that have high betweenness are the gatekeepers of information, because of their relative location in the network.

The formula for node betweenness centrality is

upper C Subscript b Baseline left-parenthesis i right-parenthesis equals sigma-summation Underscript StartLayout 1st Row  left-parenthesis s comma t right-parenthesis element-of upper N times upper N colon 2nd Row  s less-than t comma sigma Subscript s t Baseline greater-than 0 EndLayout Endscripts StartFraction sigma Subscript s t Baseline left-parenthesis i right-parenthesis Over sigma Subscript s t Baseline EndFraction

when DIRECTION=UNDIRECTED, or

upper C Subscript b Baseline left-parenthesis i right-parenthesis equals sigma-summation Underscript StartLayout 1st Row  left-parenthesis s comma t right-parenthesis element-of upper N times upper N colon 2nd Row  s not-equals t comma sigma Subscript s t Baseline greater-than 0 EndLayout Endscripts StartFraction sigma Subscript s t Baseline left-parenthesis i right-parenthesis Over sigma Subscript s t Baseline EndFraction

when DIRECTION=DIRECTED, where sigma Subscript s t is the number of shortest paths from s to t and sigma Subscript s t Baseline left-parenthesis i right-parenthesis is the number of shortest paths from s to t that pass through node i. As with closeness centrality, the shortest path is calculated with respect to the link weight that is defined by the AUXWEIGHT= option in the LINKSVAR statement. If the auxiliary link weight is not specified, then the link weight defaults to 1 slash w, where w represents the weight that is assigned by the WEIGHT= option in the LINKSVAR statement. By default, this means that a higher link weight implies a stronger relationship between the link’s nodes.

By default, this metric is normalized by dividing by upper K left-parenthesis upper N minus StartSet i EndSet right-parenthesis, the number of links in the complete graph on node set upper N minus StartSet i EndSet. You can disable this normalization by using the BETWEENNORM= option.

The formula for link betweenness centrality is

upper C Subscript b Baseline left-parenthesis i comma j right-parenthesis equals sigma-summation Underscript StartLayout 1st Row  left-parenthesis s comma t right-parenthesis element-of upper N times upper N colon 2nd Row  s less-than t comma sigma Subscript s t Baseline greater-than 0 EndLayout Endscripts StartFraction sigma Subscript s t Baseline left-parenthesis i comma j right-parenthesis Over sigma Subscript s t Baseline EndFraction

when DIRECTION=UNDIRECTED, or

upper C Subscript b Baseline left-parenthesis i comma j right-parenthesis equals sigma-summation Underscript StartLayout 1st Row  left-parenthesis s comma t right-parenthesis element-of upper N times upper N colon 2nd Row  s not-equals t comma sigma Subscript s t Baseline greater-than 0 EndLayout Endscripts StartFraction sigma Subscript s t Baseline left-parenthesis i comma j right-parenthesis Over sigma Subscript s t Baseline EndFraction

when DIRECTION=DIRECTED, where sigma Subscript s t Baseline left-parenthesis i comma j right-parenthesis is the number of shortest paths from s to t that pass through link left-parenthesis i comma j right-parenthesis.

By default, this metric is normalized by dividing by upper K left-parenthesis upper N right-parenthesis, the number of links in the complete graph on node set N. You can disable this normalization by using the BETWEENNORM= option.

For directed graphs, because the paths are directed, only the out-betweenness is computed. To get the in-betweenness, you must reverse all the directions of the graph and run the procedure again. You can accomplish this by simply using the LINKSVAR statement to reverse the interpretation of from and to.

Betweenness centrality is calculated using the value of the BETWEEN= option in the CENTRALITY statement. As with closeness centrality, if BETWEEN=WEIGHT (or BETWEEN=BOTH), then the calculation of shortest paths is performed using the weighted graph.

The algorithm that PROC NETWORK uses to compute betweenness centrality relies on calculating shortest paths for all source-sink pairs and runs in time upper O left-parenthesis StartAbsoluteValue upper N EndAbsoluteValue times left-parenthesis StartAbsoluteValue upper N EndAbsoluteValue log StartAbsoluteValue upper N EndAbsoluteValue plus StartAbsoluteValue upper E EndAbsoluteValue right-parenthesis right-parenthesis. Therefore, it is not expected to scale to very large graphs. As with closeness centrality, because shortest path computations can be calculated independently (for each source node), the algorithm uses multiple threads and multiple machines (depending on your session configuration and license). When closeness and betweenness centrality are run together, PROC NETWORK calculates both metrics in one pass.

You can compute an approximation of betweenness centrality by using the SAMPLEPERCENT= option in the CENTRALITY statement (AlGhamdi et al. 2017). The value that you specify for this option (p) defines the percentage of source nodes to use in calculating shortest paths. In this case the algorithm runs in time upper O left-parenthesis StartFraction p StartAbsoluteValue upper N EndAbsoluteValue Over 100 EndFraction times left-parenthesis StartAbsoluteValue upper N EndAbsoluteValue log StartAbsoluteValue upper N EndAbsoluteValue plus StartAbsoluteValue upper E EndAbsoluteValue right-parenthesis right-parenthesis. If p equals 100, then PROC NETWORK computes betweenness centrality exactly.

OUTNODES= Data Table

The node betweenness centrality results are provided in the nodes output data table that you specify in the OUTNODES= option in the PROC NETWORK statement.

The OUTNODES= data table contains the betweenness centrality of each node. This data table contains the following column:

  • node: the node label

If you specify BETWEEN=UNWEIGHT or BETWEEN=BOTH, the following column also appears in the nodes output data table:

  • centr_between_unwt: the unweighted betweenness centrality of the node

If you specify BETWEEN=WEIGHT or BETWEEN=BOTH, the following column also appears in the nodes output data table:

  • centr_between_wt: the weighted betweenness centrality of the node

Betweenness Centrality of a Directed Graph

Consider again the directed graph in Figure 7 with data table mylib.LinkSetIn, which is defined in the section Links Input Data. The following statements calculate the betweenness centrality for both the weighted and unweighted graphs:

proc network
   direction  = directed
   links      = mylib.LinkSetIn
   outLinks   = mylib.LinkSetOut
   outNodes   = mylib.NodeSetOut;
   centrality
      between = both;
run;

The nodes data table mylib.NodeSetOut now contains the weighted and unweighted node betweenness centrality of the input graph. This data table is shown in Figure 63.

Figure 63: Node Betweenness Centrality of a Directed Graph

nodecentr_between_wtcentr_between_unwt
F0.267860.26786
G0.214290.21429
E0.178570.17857
B0.071430.07738
D0.017860.00595
A0.000000.00000
C0.000000.00595
H0.000000.00000
I0.000000.00000


In addition, the links data table mylib.LinkSetOut contains the weighted and unweighted link betweenness centrality of the input graph. This data table is shown in Figure 64.

Figure 64: Link Betweenness Centrality of a Directed Graph

fromtoweightcentr_between_wtcentr_between_unwt
FG60.250000.25000
EF20.166670.16667
BF50.111110.11111
GH10.097220.09722
GI10.097220.09722
CE10.083330.08796
DE10.083330.07407
AB10.069440.07407
ED10.041670.04167
AD40.027780.01852
BE20.027780.03241
AC20.013890.01852
BC10.013890.01389
HG20.013890.01389
HI30.013890.01389


For more detailed examples, see Example 2.3: Betweenness and Closeness Centrality for Computer Network Topology and Example 2.4: Betweenness and Closeness Centrality for Project Groups in a Research Department.

Eigenvector Centrality

Eigenvector centrality is an extension of degree centrality in which centrality points are awarded for each neighbor. However, not all neighbors are equally important. Intuitively, a connection to an important node should contribute more to the centrality score than a connection to a less important node. This is the basic idea behind eigenvector centrality. The eigenvector centrality of a node is defined to be proportional to the sum of the scores of all nodes that are connected to it. Mathematically, it is represented as

x Subscript i Baseline equals StartFraction 1 Over lamda EndFraction sigma-summation Underscript j element-of upper N Endscripts w Subscript i j Baseline x Subscript j

when DIRECTION=UNDIRECTED, or

x Subscript i Baseline equals StartFraction 1 Over lamda EndFraction sigma-summation Underscript j element-of upper N Endscripts w Subscript i j Baseline x Subscript j

when DIRECTION=DIRECTED, where x Subscript i is the eigenvector centrality of node i, w Subscript i j is the sum of the weights of links from node i to node j, and lamda is a constant.

The right eigenvector equation in matrix form can be written as:

bold upper A bold x equals lamda bold x

where, for an undirected graph, bold upper A represents the (symmetric) adjacency matrix that corresponds to the link weights in E, or for a directed graph, bold upper A, represents the adjacency matrix that corresponds to the outgoing link weights in E. To calculate the left eigenvector, which corresponds to the incoming link weights, switch the orientation of the from and to variables in the data table by using the LINKSVAR= statement. In constructing the matrix bold upper A, the weights of multilinks are aggregated. Eigenvector centrality is defined as the principal eigenvector bold x that corresponds to the largest eigenvalue lamda.

To solve this eigenvector problem, PROC NETWORK provides two algorithms: the Jacobi-Davidson algorithm and the power method. You can use the EIGENALGORITHM= option in the CENTRALITY statement to specify which algorithm to use. EIGENALGORITHM=JACOBIDAVIDSON, which is the default, specifies the Jacobi-Davidson algorithm for solving large-scale eigenvalue problems (Sleijpen and van der Vorst 2000). The power method is one of the standard algorithms for solving eigenvalue problems, but it converges slowly for certain problems.

Eigenvector centrality is calculated using the value that you specify in the EIGEN= option in the CENTRALITY statement.

OUTNODES= Data Table

The results are provided in the nodes output data table that you specify in the OUTNODES= option in the PROC NETWORK statement.

The OUTNODES= data table contains the eigenvector centrality of each node. This data table contains the following column:

  • node: the node label

If you specify EIGEN=UNWEIGHT or EIGEN=BOTH, the following column also appears in the nodes output data table:

  • centr_eigen_unwt: the unweighted eigenvector centrality of the node

If you specify EIGEN=WEIGHT or EIGEN=BOTH, the following column also appears in the nodes output data table:

  • centr_eigen_wt: the weighted eigenvector centrality of the node

Eigenvector Centrality of an Undirected Graph

The following example illustrates the use of eigenvector centrality on the undirected graph G shown in Figure 65.

Figure 65: Eigenvector Centrality Example of an Undirected Graph

Eigenvector Centrality Example of an Undirected Graph


The graph can be represented by the following links data table, mylib.LinkSetIn:

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

The following statements compute the eigenvector centrality:

proc network
   links      = mylib.LinkSetIn
   outNodes   = mylib.NodeSetOut;
   centrality
      eigen   = unweight;
run;

The output data table mylib.NodeSetOut now contains the eigenvector centrality of each node, as shown in Figure 66.

Figure 66: Eigenvector Centrality Output

nodecentr_eigen_unwt
B1.00000
E0.75919
F0.61981
D0.40226
I0.35233
J0.35233
C0.35233
G0.26749
H0.26749
A0.14173


Even though nodes F and D both have the same degree of 2, node F has a higher eigenvector centrality than node D. This is because node F links to two important nodes (B and E), whereas node D links to one important node (B) and one unimportant node (A).

For a more detailed example, see Example 2.5: Eigenvector Centrality for Word Sense Disambiguation.

Hub and Authority Scoring

Hub and authority centrality was originally developed by Kleinberg (1998) to rank the importance of web pages. Certain web pages (called hubs) are important in the sense that they point to many important pages. On the other hand, some web pages (called authorities) are important because they are pointed to by many important pages. In other words, a good hub node is one that points to many good authorities, and a good authority node is one that is pointed to by many good hub nodes. This idea can be applied to many other types of graphs besides web pages. For example, you can apply it to a citation network for journal articles. A review article that cites many good authority papers has a high hub score, whereas a paper that is referenced by many other papers has a high authority score. The section Authority in US Supreme Court Precedent presents a similar example.

The authority centrality of a node is proportional to the sum of the hub centrality of nodes that point to it. Similarly, the hub centrality of a node is proportional to the sum of the authorities of nodes that it points to. That is,

StartLayout 1st Row 1st Column x Subscript i 2nd Column equals alpha sigma-summation Underscript j element-of upper N Endscripts w Subscript j i Baseline y Subscript j Baseline 2nd Row 1st Column y Subscript j 2nd Column equals beta sigma-summation Underscript i element-of upper N Endscripts w Subscript i j Baseline x Subscript i EndLayout

where x Subscript i is the authority centrality of node i, y Subscript j is the hub centrality of node j, w Subscript i j is the sum of the weights of links from node i to node j, and alpha and beta are constants.

Similar to eigenvector centrality, the definitions of authority and hub centrality can be written in matrix form as

StartLayout 1st Row 1st Column bold x 2nd Column equals alpha bold upper A Superscript down-tack Baseline bold y 2nd Row 1st Column bold y 2nd Column equals beta bold upper A bold x EndLayout

where bold upper A represents the adjacency matrix that corresponds to the outgoing link weights in E and bold upper A Superscript down-tack represents the adjacency matrix that corresponds to the incoming link weights in E. In constructing the matrices bold upper A and bold upper A Superscript down-tack, the weights of multilinks are aggregated.

Combining the two equations results in

StartLayout 1st Row 1st Column bold upper A Superscript down-tack Baseline bold upper A bold x 2nd Column equals lamda bold x 2nd Row 1st Column bold upper A bold upper A Superscript down-tack Baseline bold y 2nd Column equals lamda bold y EndLayout

where lamda equals left-parenthesis alpha beta right-parenthesis Superscript negative 1. Thus, the authority and hub centralities are the principal eigenvectors of bold upper A Superscript down-tack Baseline bold upper A and bold upper A bold upper A Superscript down-tack, respectively.

To solve this eigenvector problem, PROC NETWORK provides two algorithms: the Jacobi-Davidson algorithm and the power method. You can use the EIGENALGORITHM= option in the CENTRALITY statement to specify which algorithm to use. EIGENALGORITHM=JACOBIDAVIDSON, which is the default, specifies the Jacobi-Davidson algorithm for solving large-scale eigenvalue problems (Sleijpen and van der Vorst 2000). The power method is one of the standard algorithms for solving eigenvalue problems, but it converges slowly for certain problems.

OUTNODES= Data Table

The results are provided in the nodes output data table that you specify in the OUTNODES= option in the PROC NETWORK statement.

The OUTNODES= data table contains the hub and authority centralities of each node. This data table contains the following column:

  • node: the node label

If you specify HUB=UNWEIGHT or HUB=BOTH, the following column also appears in the nodes output data table:

  • centr_hub_unwt: the unweighted hub centrality of the node

If you specify HUB=WEIGHT or HUB=BOTH, the following column also appears in the nodes output data table:

  • centr_hub_wt: the weighted hub centrality of the node

If you specify AUTH=UNWEIGHT or AUTH=BOTH, the following column also appears in the nodes output data table:

  • centr_auth_unwt: the unweighted authority centrality of the node

If you specify AUTH=WEIGHT or AUTH=BOTH, the following column also appears in the nodes output data table:

  • centr_auth_wt: the weighted authority centrality of the node

Hub and Authority Centrality of a Directed Graph

The following example illustrates the use of hub and authority scoring on the directed graph G shown in Figure 67. Each node represents a web page. If web page i has a hyperlink that points to web page j, then there is a directed link from i to j.

Figure 67: Hub and Authority Centrality Example of a Directed Graph

Hub and Authority Centrality Example of a Directed Graph


The graph can be represented by the following links data table, mylib.LinkSetIn:

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

The following statements compute hub and authority centrality:

proc network
   direction   = directed
   links       = mylib.LinkSetIn
   outNodes    = mylib.NodeSetOut;
   centrality
      hub      = unweight
      auth     = unweight;
run;

The output data table mylib.NodeSetOut now contains the hub and authority scores of each node, as shown in Figure 68.

Figure 68: Hub and Authority Centrality Output

nodecentr_hub_unwtcentr_auth_unwt
K1.000000.00000
F1.000000.11466
I1.000000.00000
J1.000000.00000
E0.665490.84725
D0.597030.11466
C0.541350.00000
G0.458650.00000
H0.458650.00000
A0.000000.10287
B0.000001.00000


The output shows that nodes B and E have high authority scores because they have many incoming links. Nodes F, I, J, and K have high hub scores because they all point to good authority nodes B and E.

PageRank Centrality

PageRank centrality, named after Google’s cofounder Larry Page, was originally proposed for the application of ranking web pages in a search engine.

The PageRank algorithm models the stationary distribution of a Markov process, assuming that each node is a web page and each link is a hyperlink from one page to another. A web surfer might choose a random link on every page or might jump to a random page on the whole web with some probability. The PageRank of a web page is the percentage of time the surfer spends on the page. Mathematically, it is defined as

x Subscript i Baseline equals StartFraction 1 minus alpha Over StartAbsoluteValue upper N EndAbsoluteValue EndFraction plus alpha left-parenthesis sigma-summation Underscript StartLayout 1st Row  j element-of upper N colon 2nd Row  w Subscript j Superscript normal o normal u normal t Baseline not-equals 0 EndLayout Endscripts StartFraction w Subscript j i Baseline Over w Subscript j Superscript normal o normal u normal t Baseline EndFraction x Subscript j Baseline plus sigma-summation Underscript StartLayout 1st Row  j element-of upper N colon 2nd Row  w Subscript j Superscript normal o normal u normal t Baseline equals 0 EndLayout Endscripts StartFraction 1 Over StartAbsoluteValue upper N EndAbsoluteValue EndFraction x Subscript j Baseline right-parenthesis

where x Subscript i is the PageRank score of node i, w Subscript i j is the sum of the weights of links from node i to node j, alpha is a damping factor, and

w Subscript i Superscript normal o normal u normal t Baseline equals sigma-summation Underscript j element-of upper N Endscripts w Subscript i j

is the sum of the outbound link weights from node i.

For the calculation of PageRank centrality, PROC NETWORK implements a version of the power method, as described in Langville and Meyer (2006). The damping factor alpha, which you can specify in the PAGERANKALPHA= option in the CENTRALITY statement, is an important concept in the PageRank algorithm. In the PageRank equation, 1 minus alpha represents the probability of jumping to a random page. Without the damping factor, pages that have no incoming links would have a PageRank score of zero, so these pages cannot be distinguished by PageRank scores. The damping factor also affects the convergence of the power method. Typically, many more iterations are required as the damping factor is set closer to 1.

When the PageRank algorithm is applied to undirected graphs, each undirected link is treated as two directed links that go in both directions.

OUTNODES= Data Table

The results are provided in the nodes output data table that you specify in the OUTNODES= option in the PROC NETWORK statement.

The OUTNODES= data table contains the PageRank centrality of each node. This data table contains the following column:

  • node: the node label

If you specify PAGERANK=UNWEIGHT or PAGERANK=BOTH, the following column also appears in the nodes output data table:

  • centr_pagerank_unwt: the unweighted PageRank centrality of the node

If you specify PAGERANK=WEIGHT or PAGERANK=BOTH, the following column also appears in the nodes output data table:

  • centr_pagerank_wt: the weighted PageRank centrality of the node

PageRank Centrality of an Undirected Graph

This section concludes with an example that illustrates the use of PageRank centrality on the directed graph G that is shown in Figure 67 in the previous section, Hub and Authority Scoring.

The following statements compute the PageRank score by using the same data as in the previous section:

proc network
   direction   = directed
   links       = mylib.LinkSetIn
   outNodes    = mylib.NodeSetOut;
   centrality
      pagerankAlpha = 0.85
      pagerank      = unweight;
run;

The output data table mylib.NodeSetOut now contains the PageRank score of each node, as shown in Figure 69.

Figure 69: PageRank Centrality of a Directed Graph (Damping Factor = 0.85)

nodecentr_pagerank_unwt
B0.38440
C0.34291
E0.08089
D0.03909
F0.03909
A0.03278
G0.01617
H0.01617
I0.01617
J0.01617
K0.01617


The PageRank score can be thought of as the percentage of time a web surfer spends on a web page. In this example, 38.4% of the surfer’s time is spent on page (node) B, and 34.3% of the surfer’s time is spent on page (node) C. Notice that node C has a higher PageRank score than node E, even though it has fewer links. The reason is that node C has an incoming link from high-value node B, whereas node E has no incoming links from high-value nodes.

The following statements modify the damping factor to be 0.999 to show the changes in PageRank scores:

proc network
   direction   = directed
   links       = mylib.LinkSetIn
   outNodes    = mylib.NodeSetOut;
   centrality
      pagerankAlpha = 0.999
      pagerank      = unweight;
run;

The new PageRank scores are shown in Figure 70.

Figure 70: PageRank Centrality of a Directed Graph (Damping Factor = 0.999)

nodecentr_pagerank_unwt
B0.49904
C0.49867
E0.00070
D0.00035
F0.00035
A0.00029
G0.00012
H0.00012
I0.00012
J0.00012
K0.00012


As expected, the scores of all nodes except B and C are getting close to zero. This is because after the web surfer arrives at pages B and C, the surfer cannot jump off the pages because there are no outbound links from nodes B and C to other nodes.

Last updated: August 07, 2026