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 datasetdata(karate)g <- karate# Calculate distinction centrality for the full networkresults_full <-distinction(g)
Full Network Results
Code
set.seed(42)# Prepare nodes and edges for visNetworkV(g)$title <-paste0("Node: ", V(g)$name, "<br>Distinction: ", round(results_full$scd, 3))# Color based on distinctionV(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)
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.