Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Social network analysis methods, metrics, and visualization tools
.claude/skills/brycewang-stanford-network-analysis-guide/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-08 | ✗→✓ | ▲ Improved | 84% | 0% |
| case-19 | ✗→✓ | ▲ Improved | 34% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 79% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 59% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 13% | 0% |
A skill for conducting social network analysis (SNA) in research contexts. Covers network data collection and representation, key structural metrics (centrality, density, clustering), community detection algorithms, ego network analysis, longitudinal network models, and visualization best practices using Python NetworkX, igraph, and Gephi.
Networks consist of nodes (actors) and edges (relationships). The first decision in any SNA project is how to represent the data.
Network data formats:
Edge List (simplest):
source, target, weight
Alice, Bob, 3
Alice, Carol, 1
Bob, David, 5
Adjacency Matrix (for small networks):
Alice Bob Carol David
Alice 0 3 1 0
Bob 3 0 0 5
Carol 1 0 0 0
David 0 5 0 0
Network types:
Undirected: friendship, co-authorship, physical contact
Directed: email, citation, following on social media
Weighted: frequency of interaction, strength of tie
Bipartite: two types of nodes (e.g., people and events)
Multiplex: multiple types of edges between same nodes
Temporal: edges have timestamps or time windowsCommon SNA data collection approaches:
Survey-based (name generators):
"List up to 5 people you go to for work advice."
Advantages: captures subjective relationship perception
Limitations: recall bias, boundary specification problem
Best for: organizational networks, personal networks
Archival data:
Email logs, collaboration records, co-authorship
Advantages: objective, complete within data boundaries
Limitations: may not reflect relationship quality
Best for: large-scale communication networks
Observation:
Systematic recording of interactions
Advantages: captures actual behavior
Limitations: time-intensive, observer effects
Best for: small groups, classroom networks
Digital trace data:
Social media follows, retweets, mentions
Advantages: large-scale, timestamped
Limitations: platform-specific behavior, not generalizable
Best for: online community studies
Important considerations:
- Boundary specification: who is included in the network?
- Complete vs sampled networks require different methods
- IRB/ethics approval needed for human subjects research
- Node anonymization required for publicationpythonimport networkx as nx def compute_centrality_measures(G): """ Compute the four classic centrality measures for all nodes. Each captures a different dimension of node importance: - Degree: connectivity (popular nodes) - Betweenness: brokerage (bridge nodes) - Closeness: reachability (efficient nodes) - Eigenvector: prestige (connected to important nodes) """ centralities = {} # Degree centrality: proportion of nodes connected to centralities["degree"] = nx.degree_centrality(G) # Betweenness: proportion of shortest paths through node centralities["betweenness"] = nx.betweenness_centrality( G, weight="weight", normalized=True ) # Closeness: inverse of average shortest path to all others centralities["closeness"] = nx.closeness_centrality(G) # Eigenvector: connected to other high-centrality nodes try: centralities["eigenvector"] = nx.eigenvector_centrality( G, max_iter=1000, weight="weight" ) except nx.PowerIterationFailedConvergence: centralities["eigenvector"] = {} return centralities
pythondef compute_network_metrics(G): """ Compute network-level structural properties. """ metrics = {} n = G.number_of_nodes() m = G.number_of_edges() metrics["nodes"] = n metrics["edges"] = m # Density: actual edges / possible edges metrics["density"] = nx.density(G) # Average clustering coefficient: transitivity tendency metrics["avg_clustering"] = nx.average_clustering(G) # Global clustering (transitivity) metrics["transitivity"] = nx.transitivity(G) # Connected components if G.is_directed(): metrics["weakly_connected_components"] = ( nx.number_weakly_connected_components(G) ) else: metrics["connected_components"] = ( nx.number_connected_components(G) ) if nx.is_connected(G): metrics["diameter"] = nx.diameter(G) metrics["avg_shortest_path"] = ( nx.average_shortest_path_length(G) ) # Degree distribution statistics degrees = [d for n, d in G.degree()] metrics["avg_degree"] = sum(degrees) / len(degrees) metrics["max_degree"] = max(degrees) return metrics def interpret_metrics(metrics): """ Provide interpretive context for network metrics. """ interpretations = [] if metrics["density"] > 0.5: interpretations.append( "High density: most actors are connected. " "Information spreads quickly but network is " "resource-intensive to maintain." ) elif metrics["density"] < 0.1: interpretations.append( "Low density: sparse connections. Network " "may have structural holes and brokerage " "opportunities." ) if metrics["avg_clustering"] > 0.5: interpretations.append( "High clustering: strong tendency to form " "closed triads. Indicates group cohesion " "and potential echo chambers." ) return interpretations
pythonimport community as community_louvain def detect_communities_multiple(G): """ Apply multiple community detection algorithms and compare. Different algorithms may reveal different structural patterns. """ results = {} # Louvain method (modularity optimization) results["louvain"] = community_louvain.best_partition( G, weight="weight" ) results["louvain_modularity"] = ( community_louvain.modularity(results["louvain"], G) ) # Label Propagation (fast, non-deterministic) lp_communities = nx.community.label_propagation_communities(G) lp_partition = {} for i, comm in enumerate(lp_communities): for node in comm: lp_partition[node] = i results["label_propagation"] = lp_partition # Girvan-Newman (edge betweenness, slow but interpretable) # Only practical for small networks (< 1000 nodes) if G.number_of_nodes() < 500: gn_communities = nx.community.girvan_newman(G) top_level = next(gn_communities) gn_partition = {} for i, comm in enumerate(top_level): for node in comm: gn_partition[node] = i results["girvan_newman"] = gn_partition return results
Ego network concepts:
Ego: the focal actor
Alters: ego's direct contacts
Ties: connections between alters (not through ego)
Key ego network measures:
- Size: number of alters
- Density: proportion of possible alter-alter ties that exist
- Constraint: Burt's measure of structural holes
- Low constraint = access to diverse information
- High constraint = redundant contacts
- Effective size: size minus redundancy of contacts
- Ego betweenness: brokerage within the ego network
Research applications:
- Social support and health outcomes
- Innovation diffusion and adoption
- Career success and social capital
- Information access and decision-makingNetwork visualization guidelines:
Layout algorithms:
- Force-directed (Fruchterman-Reingold, ForceAtlas2):
Best for: showing clusters, general structure
Use when: exploring data, presenting to general audience
- Circular: Best for: showing connectivity patterns
Use when: comparing density across groups
- Hierarchical (Sugiyama): Best for: directed acyclic graphs
Use when: showing flow or hierarchy
Visual encoding:
- Node size: proportional to centrality or attribute value
- Node color: community membership or categorical attribute
- Edge width: relationship strength or frequency
- Edge color: relationship type (in multiplex networks)
Publication standards:
- Use colorblind-friendly palettes
- Include a legend for all visual encodings
- Report the layout algorithm used
- State N (nodes) and M (edges) in the caption
- For large networks, consider filtering to top-k nodes
- Provide the network data in supplementary materials
Tools:
- Gephi: interactive exploration, ForceAtlas2 layout
- Python pyvis: interactive HTML visualizations
- R igraph: publication-quality static figures
- Cytoscape: biological networks, rich plugin ecosystemSocial network analysis provides a structural perspective on social phenomena that complements traditional individual-level analyses. By examining patterns of relationships rather than attributes of individuals, SNA reveals how position in a social structure shapes behavior, information access, influence, and outcomes.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 54,225 | 46,538 | -14% | 1 | 1 | 0% | 3,988 | 5,537 | +39% | 0 | 0 | — |
case-02 | fail→fail | 23,896 | 49,505 | +107% | 1 | 1 | 0% | 3,236 | 5,217 | +61% | 0 | 0 | — |
case-03 | pass→pass | 18,427 | 53,030 | +188% | 1 | 1 | 0% | 3,739 | 6,687 | +79% | 0 | 0 | — |
case-04 | pass→pass | 19,215 | 18,030 | -6% | 1 | 1 | 0% | 3,424 | 5,447 | +59% | 0 | 0 | — |
case-05 | pass→pass | 24,798 | 22,306 | -10% | 1 | 1 | 0% | 5,096 | 5,749 | +13% | 0 | 0 | — |
case-06 | fail→fail | 13,158 | 44,342 | +237% | 1 | 1 | 0% | 2,361 | 4,753 | +101% | 0 | 0 | — |
case-07 | pass→pass | 12,499 | 8,304 | -34% | 1 | 1 | 0% | 2,203 | 3,825 | +74% | 0 | 0 | — |
case-08 | fail→pass | 15,771 | 16,908 | +7% | 1 | 1 | 0% | 2,886 | 5,324 | +84% | 0 | 0 | — |
case-09 | pass→pass | 15,161 | 15,858 | +5% | 1 | 1 | 0% | 2,414 | 4,442 | +84% | 0 | 0 | — |
case-10 | pass→pass | 16,906 | 14,840 | -12% | 1 | 1 | 0% | 2,521 | 4,547 | +80% | 0 | 0 | — |
case-11 | pass→pass | 8,166 | 9,627 | +18% | 1 | 1 | 0% | 1,704 | 4,093 | +140% | 0 | 0 | — |
case-12 | fail→fail | 13,217 | 13,249 | +0% | 1 | 1 | 0% | 2,309 | 4,520 | +96% | 0 | 0 | — |
case-13 | pass→pass | 16,736 | 14,063 | -16% | 1 | 1 | 0% | 2,315 | 4,554 | +97% | 0 | 0 | — |
case-14 | pass→pass | 15,816 | 20,843 | +32% | 1 | 1 | 0% | 2,822 | 5,813 | +106% | 0 | 0 | — |
case-15 | pass→pass | 16,293 | 21,059 | +29% | 1 | 1 | 0% | 2,213 | 5,272 | +138% | 0 | 0 | — |
case-16 | pass→pass | 14,453 | 23,240 | +61% | 1 | 1 | 0% | 2,378 | 5,643 | +137% | 0 | 0 | — |
case-17 | fail→fail | 22,342 | 15,599 | -30% | 1 | 1 | 0% | 2,395 | 4,760 | +99% | 0 | 0 | — |
case-18 | pass→pass | 15,481 | 14,574 | -6% | 1 | 1 | 0% | 2,062 | 4,353 | +111% | 0 | 0 | — |
case-19 | fail→pass | 17,467 | 6,111 | -65% | 1 | 1 | 0% | 2,358 | 3,168 | +34% | 0 | 0 | — |
case-20 | pass→pass | 6,669 | 5,687 | -15% | 1 | 1 | 0% | 1,206 | 3,279 | +172% | 0 | 0 | — |
case-21 | pass→pass | 19,340 | 17,180 | -11% | 1 | 1 | 0% | 2,980 | 4,897 | +64% | 0 | 0 | — |
case-22 | pass→pass | 18,502 | 16,258 | -12% | 1 | 1 | 0% | 2,543 | 4,516 | +78% | 0 | 0 | — |
case-23 | pass→pass | 17,720 | 21,744 | +23% | 1 | 1 | 0% | 2,731 | 5,579 | +104% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 23 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.