Examples

This page provides an example of how to compute and visualize distinction centrality using the classic Zachary’s Karate Club network.

Code
library(igraph)
library(dplyr)
library(networkdata)
library(patchwork)
library(DT)
library(visNetwork)
source("../Functions/distinction.R")
source("../Functions/plot.graph.norm.R")

# Load the Karate Club dataset
data(karate)
g <- karate

# Calculate distinction centrality for the full network
results_full <- distinction(g)

Full Network Results

Code
set.seed(42)
# Prepare nodes and edges for visNetwork
V(g)$title <- paste0("Node: ", V(g)$name, "<br>Distinction: ", round(results_full$scd, 3))
# Color based on distinction
V(g)$color <- ifelse(results_full$scd > 0.05, "blue", 
              ifelse(results_full$scd < -0.05, "tan", "purple"))
V(g)$color[which.max(results_full$scd)] <- "red"

visIgraph(g) %>%
  visOptions(highlightNearest = TRUE, nodesIdSelection = TRUE) %>%
  visInteraction(hover = TRUE) %>%
  visLayout(randomSeed = 42)

Top Nodes (Club President Removed)

Code
# Load and analyze the network without the Club President (Node 34)
g_no <- delete_vertices(g, "34")
results_no <- distinction(g_no)
Code
set.seed(42)
V(g_no)$title <- paste0("Node: ", V(g_no)$name, "<br>Distinction: ", round(results_no$scd, 3))
V(g_no)$color <- ifelse(results_no$scd > 0.05, "blue", 
                 ifelse(results_no$scd < -0.05, "tan", "purple"))
V(g_no)$color[which.max(results_no$scd)] <- "red"

visIgraph(g_no) %>%
  visOptions(highlightNearest = TRUE, nodesIdSelection = TRUE) %>%
  visInteraction(hover = TRUE) %>%
  visLayout(randomSeed = 42)

Analysis

The comparison highlights how the network hierarchy shifts in the absence of a primary broker. In the full network, the club president (Node 34) commands the highest distinction score, closely followed by the instructor (Node 1). Both act as central brokers for their respective factions.

When the president is removed, the distinction scores of the remaining members are recalculated based on their new relative network positions. The instructor (Node 1) experiences significant gains in distinction centrality, taking over as the absolute primary broker in the fragmented structure. Meanwhile, nodes that relied heavily on the president for their structural position (such as Node 33) experience a drop in their relative distinction ranking. This illustrates how individual distinction is intrinsically linked to the presence or absence of key central players.