Describing a network
An edge list says who is tied to whom. Learn how the app turns it into a network, what density, clustering, assortativity and centrality measure, and how to read the map, the matrix and the degree curve.
What runs in CodeSplash
You will be able to
- Set up a network from an edge list, with an optional node table
- Read size, density, separate parts, clustering and assortativity
- Tell degree, betweenness, closeness, eigenvector centrality and PageRank apart
- Keep node results as a dataset of their own
From rows to ties
ReadMost tables have one row per thing. An edge listEdge listA table with one row per tie: the two nodes it joins and, optionally, a weight or a time. has one row per tie: the two nodes it joins, and maybe a weight. A second table, the node tableNode tableAn optional second table with one row per node: its id, a label and attributes, joined to the network by id., can add one row per node with a label and attributes.
Before any measure runs, the app reads the edge list once. It drops rows with a missing end, merges repeated edges (adding their weights), leaves self-loops out, and puts the nodes in a fixed order. Python and R read the same result, so both describe the same network.
The karate club
ExploreIn the 1970s Wayne Zachary recorded the friendships among 34 members of a university karate club. A quarrel split the club in two. The edge list has 78 friendships, each weighted by the number of settings in which the pair met.
View data
| x | y | person | degree | team | from | to |
|---|---|---|---|---|---|---|
| 0.9470 | 0.0170 | Des-1 | 4 | Design | 0 | 1 |
| 0.8260 | 0.1750 | Des-2 | 5 | Design | 0 | 7 |
| 0.6950 | 0.2280 | Des-3 | 6 | Design | 0 | 8 |
| 0.4920 | 0.3110 | Des-4 | 6 | Design | 0 | 11 |
| 0.3860 | 0.1840 | Des-5 | 4 | Design | 1 | 2 |
| 0.2960 | −0.0400 | Des-6 | 2 | Design | 1 | 4 |
| 0.4430 | −0.1380 | Des-7 | 3 | Design | 1 | 8 |
| 0.5310 | −0.2670 | Des-8 | 4 | Design | 1 | 28 |
| 0.7340 | −0.2650 | Des-9 | 4 | Design | 2 | 3 |
| 0.8550 | −0.2200 | Des-10 | 4 | Design | 2 | 6 |
| −0.0770 | 0.5650 | Eng-1 | 4 | Engineering | 2 | 8 |
| −0.1470 | 0.6850 | Eng-2 | 5 | Engineering | 2 | 9 |
| −0.2300 | 0.8190 | Eng-3 | 2 | Engineering | 2 | 11 |
| −0.4100 | 0.7720 | Eng-4 | 5 | Engineering | 3 | 4 |
| −0.5010 | 0.6470 | Eng-5 | 3 | Engineering | 3 | 5 |
| −0.5550 | 0.5100 | Eng-6 | 3 | Engineering | 3 | 7 |
| −0.5230 | 0.4220 | Eng-7 | 3 | Engineering | 3 | 24 |
| −0.3910 | 0.2320 | Eng-8 | 4 | Engineering | 3 | 29 |
| −0.1720 | 0.2530 | Eng-9 | 6 | Engineering | 4 | 9 |
| −0.0340 | 0.3630 | Eng-10 | 5 | Engineering | 4 | 22 |
| 0.0220 | −0.5120 | Sal-1 | 6 | Sales | 5 | 7 |
| −0.0140 | −0.3800 | Sal-2 | 1 | Sales | 6 | 7 |
| −0.2370 | −0.2210 | Sal-3 | 3 | Sales | 6 | 9 |
| −0.3810 | −0.2810 | Sal-4 | 6 | Sales | 8 | 9 |
| −0.5410 | −0.3290 | Sal-5 | 7 | Sales | 10 | 11 |
| −0.5700 | −0.5090 | Sal-6 | 4 | Sales | 10 | 13 |
| −0.5450 | −0.7170 | Sal-7 | 3 | Sales | 10 | 18 |
| −0.4070 | −0.7670 | Sal-8 | 5 | Sales | 10 | 19 |
| −0.2460 | −0.7870 | Sal-9 | 5 | Sales | 11 | 13 |
| −0.1000 | −0.6820 | Sal-10 | 6 | Sales | 11 | 16 |
| — | — | — | — | — | 12 | 14 |
| — | — | — | — | — | 12 | 16 |
| — | — | — | — | — | 13 | 15 |
| — | — | — | — | — | 13 | 17 |
| — | — | — | — | — | 13 | 24 |
| — | — | — | — | — | 14 | 17 |
| — | — | — | — | — | 14 | 18 |
| — | — | — | — | — | 15 | 18 |
| — | — | — | — | — | 15 | 19 |
| — | — | — | — | — | 16 | 18 |
| — | — | — | — | — | 17 | 18 |
| — | — | — | — | — | 17 | 19 |
| — | — | — | — | — | 18 | 19 |
| — | — | — | — | — | 19 | 28 |
| — | — | — | — | — | 20 | 23 |
| — | — | — | — | — | 20 | 25 |
| — | — | — | — | — | 20 | 26 |
| — | — | — | — | — | 20 | 27 |
| — | — | — | — | — | 20 | 28 |
| — | — | — | — | — | 20 | 29 |
| — | — | — | — | — | 21 | 24 |
| — | — | — | — | — | 22 | 27 |
| — | — | — | — | — | 22 | 28 |
| — | — | — | — | — | 23 | 24 |
| — | — | — | — | — | 23 | 25 |
| — | — | — | — | — | 23 | 26 |
| — | — | — | — | — | 23 | 27 |
| — | — | — | — | — | 23 | 28 |
| — | — | — | — | — | 24 | 25 |
| — | — | — | — | — | 24 | 27 |
First 60 of 64 rows.
The map places tied members close together. Only the distances between dots mean something; the axes don't.
Make a guess
PredictPredict first
There are 34 members and 78 friendships. What share of all possible pairs are friends (the density)?
Make your guess between 0 and 1 share of pairs, then reveal.
Reveal
The density is 0.139: 78 of 561 possible pairs. Real networks are sparse, and the bigger they get, the sparser.
Friends of friends
CheckpointTransitivityTransitivityShare of connected triples (A–B–C) that close into a triangle: how often a friend of a friend is a friend. is the share of "A knows B, B knows C" chains that close into a triangle. In the club it's 0.256. The average local clustering is 0.571.
Degree assortativityDegree assortativityCorrelation between the degrees at the two ends of each edge: positive when hubs link to hubs, negative when hubs link to small nodes. asks whether well-connected members befriend each other. In the unweighted club it's −0.476: the two leaders' many friends are mostly members with few ties.
Check yourself
A network's degree assortativity is −0.48. What does that say?
Show the answer
Answer: b
Assortativity is a correlation between the degrees at the two ends of each edge. Negative values mean hubs connect to small nodes, as in a club organized around two leaders.
Who is central?
In the appA undirected network of 34 nodes and 78 edges (density 0.139); 1 part(s), the largest with 34 nodes.
- Nodes
- 34
- Edges
- 78
- Density
- 0.1390
- Separate parts
- 1
- Transitivity
- 0.2557
- Degree assortativity
- −0.4756
Plots
View data
| From | club | Node | Degree | To | Weight | x | y |
|---|---|---|---|---|---|---|---|
| 0 | Mr. Hi | 0 | 16 | 1 | 4 | −0.3181 | −0.2545 |
| 0 | Mr. Hi | 1 | 9 | 2 | 2 | −0.2233 | −0.0757 |
| 0 | Mr. Hi | 10 | 3 | 3 | 3 | −0.5988 | −0.5538 |
| 0 | Mr. Hi | 11 | 1 | 4 | 1 | −0.7684 | −0.3116 |
| 0 | Mr. Hi | 12 | 2 | 5 | 3 | −0.5555 | −0.3153 |
| 0 | Mr. Hi | 13 | 5 | 9 | 2 | −0.0383 | −0.1016 |
| 0 | Officer | 14 | 2 | 11 | 2 | 0.6563 | 0.2455 |
| 0 | Officer | 15 | 2 | 12 | 5 | 0.5571 | −0.0469 |
| 0 | Mr. Hi | 16 | 2 | 14 | 2 | −0.5525 | −1 |
| 0 | Mr. Hi | 17 | 2 | 23 | 3 | −0.5518 | −0.1334 |
| 0 | Officer | 18 | 2 | 25 | 2 | 0.6951 | 0.1440 |
| 0 | Mr. Hi | 19 | 3 | 28 | 3 | −0.1218 | 0.0626 |
| 0 | Mr. Hi | 2 | 10 | 29 | 3 | −0.0184 | 0.0461 |
| 0 | Officer | 20 | 2 | 30 | 3 | 0.6496 | 0.0363 |
| 0 | Mr. Hi | 21 | 2 | 31 | 2 | −0.5239 | −0.0045 |
| 0 | Officer | 22 | 2 | 32 | 2 | 0.6464 | 0.3546 |
| 1 | Officer | 23 | 5 | 5 | 5 | 0.3325 | 0.4993 |
| 1 | Officer | 24 | 3 | 9 | 1 | −0.0504 | 0.6329 |
| 1 | Officer | 25 | 3 | 11 | 2 | 0.1108 | 0.6623 |
| 1 | Officer | 26 | 2 | 12 | 6 | 0.6203 | 0.5661 |
| 1 | Officer | 27 | 4 | 14 | 2 | 0.1293 | 0.4353 |
| 1 | Officer | 28 | 3 | 23 | 3 | 0.1494 | 0.2290 |
| 1 | Officer | 29 | 4 | 24 | 2 | 0.5085 | 0.4495 |
| 1 | Mr. Hi | 3 | 6 | 31 | 4 | −0.2882 | −0.1638 |
| 2 | Officer | 30 | 4 | 28 | 3 | 0.2164 | −0.0296 |
| 2 | Officer | 31 | 6 | 29 | 3 | 0.0165 | 0.2593 |
| 4 | Officer | 32 | 12 | 23 | 3 | 0.4004 | 0.1628 |
| 5 | Officer | 33 | 17 | 12 | 3 | 0.3249 | 0.2115 |
| 5 | Mr. Hi | 4 | 3 | 23 | 3 | −0.4335 | −0.5876 |
| 5 | Mr. Hi | 5 | 4 | 27 | 3 | −0.5362 | −0.7094 |
| 6 | Mr. Hi | 6 | 4 | 26 | 3 | −0.4075 | −0.7379 |
| 6 | Mr. Hi | 7 | 4 | 27 | 2 | −0.1466 | −0.2632 |
| 7 | Mr. Hi | 8 | 5 | 26 | 3 | 0.1237 | −0.0736 |
| 7 | Officer | 9 | 2 | 27 | 4 | −0.0040 | 0.3656 |
| 8 | — | — | — | 29 | 3 | — | — |
| 8 | — | — | — | 30 | 3 | — | — |
| 10 | — | — | — | 26 | 1 | — | — |
| 10 | — | — | — | 27 | 2 | — | — |
| 11 | — | — | — | 27 | 1 | — | — |
| 12 | — | — | — | 20 | 2 | — | — |
| 12 | — | — | — | 21 | 2 | — | — |
| 12 | — | — | — | 23 | 3 | — | — |
| 12 | — | — | — | 26 | 2 | — | — |
| 12 | — | — | — | 31 | 4 | — | — |
| 12 | — | — | — | 32 | 5 | — | — |
| 12 | — | — | — | 33 | 1 | — | — |
| 13 | — | — | — | 26 | 3 | — | — |
| 13 | — | — | — | 27 | 1 | — | — |
| 15 | — | — | — | 26 | 2 | — | — |
| 15 | — | — | — | 27 | 3 | — | — |
| 16 | — | — | — | 18 | 5 | — | — |
| 16 | — | — | — | 20 | 4 | — | — |
| 16 | — | — | — | 22 | 3 | — | — |
| 16 | — | — | — | 26 | 5 | — | — |
| 16 | — | — | — | 27 | 4 | — | — |
| 17 | — | — | — | 18 | 2 | — | — |
| 17 | — | — | — | 20 | 3 | — | — |
| 17 | — | — | — | 25 | 2 | — | — |
| 18 | — | — | — | 25 | 7 | — | — |
| 19 | — | — | — | 22 | 4 | — | — |
First 60 of 78 rows.
View data
| Degree k | Degree | Share of nodes with degree ≥ k |
|---|---|---|
| 1 | Degree | 1 |
| 2 | Degree | 0.9706 |
| 3 | Degree | 0.6471 |
| 4 | Degree | 0.4706 |
| 5 | Degree | 0.2941 |
| 6 | Degree | 0.2059 |
| 9 | Degree | 0.1471 |
| 10 | Degree | 0.1176 |
| 12 | Degree | 0.0882 |
| 16 | Degree | 0.0588 |
| 17 | Degree | 0.0294 |
View data
| Column | club | Node | Order | Row | Weight |
|---|---|---|---|---|---|
| 1 | Mr. Hi | 0 | 0 | 0 | 4 |
| 2 | Mr. Hi | 1 | 12 | 0 | 2 |
| 3 | Mr. Hi | 10 | 1 | 0 | 3 |
| 4 | Mr. Hi | 11 | 23 | 0 | 1 |
| 5 | Mr. Hi | 12 | 5 | 0 | 3 |
| 9 | Mr. Hi | 13 | 32 | 0 | 2 |
| 11 | Officer | 14 | 29 | 0 | 2 |
| 12 | Officer | 15 | 30 | 0 | 5 |
| 14 | Mr. Hi | 16 | 31 | 0 | 2 |
| 23 | Mr. Hi | 17 | 2 | 0 | 3 |
| 25 | Officer | 18 | 11 | 0 | 2 |
| 28 | Mr. Hi | 19 | 28 | 0 | 3 |
| 29 | Mr. Hi | 2 | 4 | 0 | 3 |
| 30 | Officer | 20 | 8 | 0 | 3 |
| 31 | Mr. Hi | 21 | 9 | 0 | 2 |
| 32 | Officer | 22 | 14 | 0 | 2 |
| 5 | Officer | 23 | 3 | 1 | 5 |
| 9 | Officer | 24 | 27 | 1 | 1 |
| 11 | Officer | 25 | 26 | 1 | 2 |
| 12 | Officer | 26 | 25 | 1 | 6 |
| 14 | Officer | 27 | 16 | 1 | 2 |
| 23 | Officer | 28 | 20 | 1 | 3 |
| 24 | Officer | 29 | 22 | 1 | 2 |
| 31 | Mr. Hi | 3 | 24 | 1 | 4 |
| 28 | Officer | 30 | 17 | 2 | 3 |
| 29 | Officer | 31 | 18 | 2 | 3 |
| 23 | Officer | 32 | 21 | 4 | 3 |
| 12 | Officer | 33 | 6 | 5 | 3 |
| 23 | Mr. Hi | 4 | 7 | 5 | 3 |
| 27 | Mr. Hi | 5 | 10 | 5 | 3 |
| 26 | Mr. Hi | 6 | 13 | 6 | 3 |
| 27 | Mr. Hi | 7 | 15 | 6 | 2 |
| 26 | Mr. Hi | 8 | 19 | 7 | 3 |
| 27 | Officer | 9 | 33 | 7 | 4 |
| 29 | — | — | — | 8 | 3 |
| 30 | — | — | — | 8 | 3 |
| 26 | — | — | — | 10 | 1 |
| 27 | — | — | — | 10 | 2 |
| 27 | — | — | — | 11 | 1 |
| 20 | — | — | — | 12 | 2 |
| 21 | — | — | — | 12 | 2 |
| 23 | — | — | — | 12 | 3 |
| 26 | — | — | — | 12 | 2 |
| 31 | — | — | — | 12 | 4 |
| 32 | — | — | — | 12 | 5 |
| 33 | — | — | — | 12 | 1 |
| 26 | — | — | — | 13 | 3 |
| 27 | — | — | — | 13 | 1 |
| 26 | — | — | — | 15 | 2 |
| 27 | — | — | — | 15 | 3 |
| 18 | — | — | — | 16 | 5 |
| 20 | — | — | — | 16 | 4 |
| 22 | — | — | — | 16 | 3 |
| 26 | — | — | — | 16 | 5 |
| 27 | — | — | — | 16 | 4 |
| 18 | — | — | — | 17 | 2 |
| 20 | — | — | — | 17 | 3 |
| 25 | — | — | — | 17 | 2 |
| 25 | — | — | — | 18 | 7 |
| 22 | — | — | — | 19 | 4 |
First 60 of 78 rows.
Most central nodes (by PageRank)
| Node | club | Degree | PageRank | Eigenvector | Clustering | Betweenness | Closeness |
|---|---|---|---|---|---|---|---|
| 33 | Officer | 17 | 0.0970 | 0.3641 | 0.1103 | 0.3041 | 0.5500 |
| 0 | Mr. Hi | 16 | 0.0885 | 0.3124 | 0.1500 | 0.4376 | 0.5690 |
| 32 | Officer | 12 | 0.0759 | 0.3323 | 0.1970 | 0.1452 | 0.5156 |
| 2 | Mr. Hi | 10 | 0.0628 | 0.3606 | 0.2444 | 0.1437 | 0.5593 |
| 1 | Mr. Hi | 9 | 0.0574 | 0.3018 | 0.3333 | 0.0539 | 0.4853 |
| 31 | Officer | 6 | 0.0420 | 0.2095 | 0.2000 | 0.1383 | 0.5410 |
| 23 | Officer | 5 | 0.0411 | 0.2180 | 0.4000 | 0.0176 | 0.3929 |
| 3 | Mr. Hi | 6 | 0.0372 | 0.1986 | 0.6667 | 0.0119 | 0.4648 |
| 5 | Mr. Hi | 4 | 0.0338 | 0.0674 | 0.5000 | 0.0300 | 0.3837 |
| 13 | Mr. Hi | 5 | 0.0335 | 0.2405 | 0.6000 | 0.0459 | 0.5156 |
| 8 | Mr. Hi | 5 | 0.0334 | 0.2470 | 0.5000 | 0.0559 | 0.5156 |
| 6 | Mr. Hi | 4 | 0.0315 | 0.0664 | 0.5000 | 0.0300 | 0.3837 |
| 25 | Officer | 3 | 0.0287 | 0.1226 | 0.3333 | 0.0038 | 0.3750 |
| 29 | Officer | 4 | 0.0283 | 0.1358 | 0.6667 | 0.0029 | 0.3837 |
| 27 | Officer | 4 | 0.0272 | 0.1477 | 0.1667 | 0.0223 | 0.4583 |
| 7 | Mr. Hi | 4 | 0.0265 | 0.1784 | 1 | 0 | 0.4400 |
| 30 | Officer | 4 | 0.0230 | 0.1583 | 0.5000 | 0.0144 | 0.4583 |
| 10 | Mr. Hi | 3 | 0.0207 | 0.0458 | 0.6667 | 0.0006 | 0.3793 |
| 4 | Mr. Hi | 3 | 0.0205 | 0.0557 | 0.6667 | 0.0006 | 0.3793 |
| 16 | Mr. Hi | 2 | 0.0168 | 0.0185 | 1 | 0 | 0.2845 |
| 24 | Officer | 3 | 0.0166 | 0.0510 | 0.3333 | 0.0022 | 0.3750 |
| 15 | Officer | 2 | 0.0164 | 0.1131 | 1 | 0 | 0.3708 |
| 26 | Officer | 2 | 0.0152 | 0.0586 | 1 | 0 | 0.3626 |
| 28 | Officer | 3 | 0.0145 | 0.0861 | 0.3333 | 0.0018 | 0.4521 |
| 19 | Mr. Hi | 3 | 0.0131 | 0.0734 | 0.3333 | 0.0325 | 0.5000 |
Network checks
| Check | Count |
|---|---|
| Edge rows | 78 |
| Edge rows left out (missing source, target or weight) | 0 |
| Self-loops | 0 |
| Repeated edges merged | 0 |
| Isolated nodes | 0 |
| Separate parts | 1 |
| Node table rows | 34 |
| Node table rows left out | 0 |
| Nodes not in the node table | 0 |
| Node table nodes with no edges | 0 |
The exact R script · R R version 4.5.1 (2025-06-13)
# Network description (size, degrees, clustering, centrality)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method describe.network 1.0.0 · spec 2393515369599210
# Dataset: graph_karate (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
library(codesplashr)
# %% Network
# The app read the edge list once and wrote the network next to this run (graph/ in the output folder):
# nodes in a fixed order, the edges, and the simple network (self-loops left out, repeated edges merged with
# their weights added). Python and R read the same files, so both describe the same network.
out_dir <- "target/academy-parity/run-8142/describe.network/karate_club/out-r"
g <- cs_graph_read(out_dir)
warnings <- g$warnings
weighted <- TRUE && isTRUE(g$weighted)
damping <- 0.85
max_path_nodes <- as.integer(5000)
seed <- 42
MAP_NODES <- 2000 # largest network drawn as a map
MATRIX_NODES <- 300 # largest network drawn as a matrix
PER_NODE <- 200 # per-node values go into the result for networks up to this size
if (weighted) {
bad <- sum(as.numeric(g$edges[["w"]]) <= 0)
if (bad > 0) cs_error("CS_E_INVALID_VALUES", column = "contexts", requirement = "positive for weighted measures (or turn off Use weights)", count = bad)
}
n <- g$n
m <- length(g$si)
meta <- g$meta
# %% Measures
# Degrees, density, reciprocity, clustering and assortativity, then one breadth-first search per node for
# betweenness, closeness and distances (Brandes 2001), then eigenvector centrality and PageRank by power
# iteration. Definitions follow networkx; the twins are codesplashr R/graph_describe.R and codesplash.
deg <- cs_graph_degrees(g)
cl <- cs_graph_clustering(g)
pa <- cs_graph_paths(g, max_path_nodes)
ev <- cs_graph_eigenvector(g, weighted)
pr <- cs_graph_pagerank(g, damping, weighted)
comp <- cs_graph_components(g)
if (!ev$converged) warnings <- c(warnings, cs_warning("CS_W_NO_CONVERGENCE", what = "Eigenvector centrality"))
if (!pr$converged) warnings <- c(warnings, cs_warning("CS_W_NO_CONVERGENCE", what = "PageRank"))
if (is.null(pa)) {
warnings <- c(warnings, sprintf("Betweenness, closeness and distances were skipped: the network has more than %d nodes.", max_path_nodes))
}
nn <- function(x) if (is.finite(x)) as.numeric(x) else NULL
degree <- deg$degree
centralization <- NULL
if (!isTRUE(g$directed) && n > 2) centralization <- sum(as.numeric(max(degree) - degree)) / ((n - 1) * (n - 2))
values <- list(
n_nodes = n,
n_edges = m,
n_edge_rows = as.integer(meta$n_edges),
density = nn(cs_graph_density(g)),
mean_degree = mean(as.numeric(degree)),
median_degree = stats::median(as.numeric(degree)),
max_degree = max(degree),
max_in_degree = if (isTRUE(g$directed)) max(deg$in_degree) else NULL,
max_out_degree = if (isTRUE(g$directed)) max(deg$out_degree) else NULL,
reciprocity = if (isTRUE(g$directed)) nn(cs_graph_reciprocity(g)) else NULL,
components = as.integer(meta$components),
largest_component = as.integer(meta$largest_component),
largest_share = as.integer(meta$largest_component) / n,
isolates = as.integer(meta$isolates),
self_loops = as.integer(meta$self_loops),
duplicate_edges = as.integer(meta$duplicate_edges),
triangles = cl$triangles,
transitivity = cl$transitivity,
avg_clustering = cl$average,
assortativity = nn(cs_graph_assortativity(g)),
degree_centralization = centralization,
avg_path_length = if (!is.null(pa)) nn(pa$avg_path_length) else NULL,
diameter = if (!is.null(pa)) nn(pa$diameter) else NULL,
max_betweenness = if (!is.null(pa)) max(pa$betweenness) else NULL,
max_closeness = if (!is.null(pa)) max(pa$closeness) else NULL,
max_eigenvector = max(ev$x),
max_pagerank = max(pr$x)
)
if (n <= PER_NODE) {
for (k in seq_len(n)) {
node <- g$node_id[k]
values[[sprintf("degree[%s]", node)]] <- degree[k]
if (isTRUE(g$directed)) {
values[[sprintf("in_degree[%s]", node)]] <- deg$in_degree[k]
values[[sprintf("out_degree[%s]", node)]] <- deg$out_degree[k]
}
values[[sprintf("clustering[%s]", node)]] <- cl$local[k]
if (!is.null(pa)) {
values[[sprintf("betweenness[%s]", node)]] <- pa$betweenness[k]
values[[sprintf("closeness[%s]", node)]] <- pa$closeness[k]
}
values[[sprintf("eigenvector[%s]", node)]] <- ev$x[k]
values[[sprintf("pagerank[%s]", node)]] <- pr$x[k]
}
}
# %% Node table
# One row per node (node_id first); the app can save it as a dataset ("Save node table as dataset").
label <- if (!is.null(g$label)) g$nodes[[g$label]] else NULL
xy <- if (n <= MAP_NODES) cs_graph_layout_fr(g, seed) else NULL
cols <- list()
if (!is.null(label)) cols[[g$label]] <- label
cols$component <- comp + 1L
cols$degree <- degree
if (isTRUE(g$directed)) {
cols$in_degree <- deg$in_degree
cols$out_degree <- deg$out_degree
}
if (isTRUE(g$weighted)) {
if (isTRUE(g$directed)) {
cols$in_strength <- deg$in_strength
cols$out_strength <- deg$out_strength
} else {
cols$strength <- deg$strength
}
}
cols$clustering <- cl$local
if (!is.null(pa)) {
cols$betweenness <- pa$betweenness
cols$closeness <- pa$closeness
}
cols$eigenvector <- ev$x
cols$pagerank <- pr$x
if (!is.null(xy)) {
cols$map_x <- xy$x
cols$map_y <- xy$y
}
artifact <- cs_graph_write_nodes(out_dir, g, cols)
# %% Tables
ord <- head(order(-pr$x, seq_len(n)), 25L)
node_cols <- list(list(key = "node", label = "Node"))
if (!is.null(label)) node_cols[[length(node_cols) + 1L]] <- list(key = "label", label = g$label)
node_cols <- c(node_cols, list(
list(key = "degree", label = "Degree", type = "integer"), list(key = "pagerank", label = "PageRank", type = "number"),
list(key = "eigenvector", label = "Eigenvector", type = "number"), list(key = "clustering", label = "Clustering", type = "number")
))
if (!is.null(pa)) {
node_cols <- c(node_cols, list(list(key = "betweenness", label = "Betweenness", type = "number"), list(key = "closeness", label = "Closeness", type = "number")))
}
rows <- lapply(ord, function(k) {
r <- list(node = g$node_id[k], degree = degree[k], pagerank = pr$x[k], eigenvector = ev$x[k], clustering = cl$local[k])
if (!is.null(label)) r$label <- if (is.na(label[k])) NULL else as.character(label[k])
if (!is.null(pa)) {
r$betweenness <- pa$betweenness[k]
r$closeness <- pa$closeness[k]
}
r
})
checks <- list(
list("Edge rows", as.integer(meta$input_rows)),
list("Edge rows left out (missing source, target or weight)", as.integer(meta$dropped_rows)),
list("Self-loops", as.integer(meta$self_loops)),
list("Repeated edges merged", as.integer(meta$duplicate_edges)),
list("Isolated nodes", as.integer(meta$isolates)),
list("Separate parts", as.integer(meta$components))
)
nt <- meta$node_table
if (!is.null(nt)) {
checks <- c(checks, list(
list("Node table rows", as.integer(nt$rows)), list("Node table rows left out", as.integer(nt$dropped_rows)),
list("Nodes not in the node table", as.integer(nt$missing_ids)), list("Node table nodes with no edges", as.integer(nt$extra_ids))
))
}
tables <- list(
list(key = "top_nodes", title = "Most central nodes (by PageRank)", columns = node_cols, rows = rows),
list(key = "checks", title = "Network checks", columns = list(list(key = "check", label = "Check"), list(key = "count", label = "Count", type = "integer")),
rows = lapply(checks, function(x) list(check = x[[1]], count = x[[2]])))
)
# %% Charts
# Node and edge columns share one chart table: shorter columns end in empty cells.
padded <- function(v, rows) c(v, rep(NA, rows - length(v)))
group <- if (!is.null(label)) ifelse(is.na(label), "(missing)", as.character(label)) else paste("part", comp + 1L)
group_title <- if (!is.null(label)) g$label else "Part"
charts <- list()
if (!is.null(xy)) {
show <- min(m, 20000L)
keep <- seq_len(show)
rows_map <- max(n, show)
charts[[length(charts) + 1L]] <- cs_chart("map", "network-graph", "Network map", list(
x = cs_col("x", padded(xy$x, rows_map), "numeric"),
y = cs_col("y", padded(xy$y, rows_map), "numeric"),
node = cs_col("Node", padded(g$node_id, rows_map), "categorical"),
size = cs_col("Degree", padded(degree, rows_map), "numeric"),
group = cs_col(group_title, padded(group, rows_map), "categorical"),
from = cs_col("From", padded(g$si[keep], rows_map), "numeric"),
to = cs_col("To", padded(g$sj[keep], rows_map), "numeric"),
weight = if (isTRUE(g$weighted)) cs_col("Weight", padded(g$sw[keep], rows_map), "numeric") else NULL
), controls = list(directed = isTRUE(g$directed)), note = if (show == m) NULL else sprintf("%d of %d edges drawn.", show, m))
} else {
charts[[length(charts) + 1L]] <- cs_chart("map", "network-graph", "Network map", list(), note = sprintf("The map is drawn for networks up to %d nodes; this one has %d.", MAP_NODES, n))
}
if (isTRUE(g$directed)) {
ci <- cs_graph_degree_ccdf(deg$in_degree)
co <- cs_graph_degree_ccdf(deg$out_degree)
ks <- c(ci$k, co$k)
ps <- c(ci$p, co$p)
series <- c(rep("In-degree", length(ci$k)), rep("Out-degree", length(co$k)))
series_levels <- c("In-degree", "Out-degree")
} else {
ca <- cs_graph_degree_ccdf(degree)
ks <- ca$k
ps <- ca$p
series <- rep("Degree", length(ca$k))
series_levels <- "Degree"
}
charts[[length(charts) + 1L]] <- cs_chart("degrees", "degree-ccdf", "Degree distribution", list(
degree = cs_col("Degree k", ks, "numeric"),
share = cs_col("Share of nodes with degree ≥ k", ps, "numeric"),
series = cs_col("Degree", series, "categorical", levels = series_levels)
))
if (n <= MATRIX_NODES) {
morder <- order(group == "(missing)", group, -degree, seq_len(n), method = "radix") - 1L
rows_mx <- max(n, m)
charts[[length(charts) + 1L]] <- cs_chart("matrix", "adjacency-matrix", "Adjacency matrix", list(
row = cs_col("Row", padded(g$si, rows_mx), "numeric"),
col = cs_col("Column", padded(g$sj, rows_mx), "numeric"),
value = cs_col(if (isTRUE(g$weighted)) "Weight" else "Edge", padded(g$sw, rows_mx), "numeric"),
node = cs_col("Node", padded(g$node_id, rows_mx), "categorical"),
group = cs_col(group_title, padded(group, rows_mx), "categorical"),
order = cs_col("Order", padded(morder, rows_mx), "numeric")
), controls = list(directed = isTRUE(g$directed)))
}
# %% Result
kind <- if (isTRUE(g$directed)) "directed" else "undirected"
dens <- if (is.null(values$density)) "undefined" else sprintf("%.3f", values$density)
summary <- sprintf("A %s network of %d nodes and %d edges (density %s); %d part(s), the largest with %d nodes.",
kind, n, m, dens, values$components, values$largest_component)
cs_publish(list(
title = "Network description (size, degrees, clustering, centrality)",
engine = cs_engine_info("jsonlite", "nanoparquet"),
n = n,
summary = summary,
statistics = list(
list(key = "n_nodes", label = "Nodes", value = n, format = "integer"),
list(key = "n_edges", label = "Edges", value = m, format = "integer"),
list(key = "density", label = "Density", value = values$density),
list(key = "components", label = "Separate parts", value = values$components, format = "integer"),
list(key = "transitivity", label = "Transitivity", value = values$transitivity),
list(key = "assortativity", label = "Degree assortativity", value = values$assortativity)
),
tables = tables,
values = values,
charts = charts,
warnings = warnings,
artifacts = list(artifact)
))
A undirected network of 34 nodes and 78 edges (density 0.139); 1 part(s), the largest with 34 nodes.
- Nodes
- 34
- Edges
- 78
- Density
- 0.1390
- Separate parts
- 1
- Transitivity
- 0.2557
- Degree assortativity
- −0.4756
To keep this page light, the plots are shown once, under the R tab.
Most central nodes (by PageRank)
| Node | club | Degree | PageRank | Eigenvector | Clustering | Betweenness | Closeness |
|---|---|---|---|---|---|---|---|
| 33 | Officer | 17 | 0.0970 | 0.3641 | 0.1103 | 0.3041 | 0.5500 |
| 0 | Mr. Hi | 16 | 0.0885 | 0.3124 | 0.1500 | 0.4376 | 0.5690 |
| 32 | Officer | 12 | 0.0759 | 0.3323 | 0.1970 | 0.1452 | 0.5156 |
| 2 | Mr. Hi | 10 | 0.0628 | 0.3606 | 0.2444 | 0.1437 | 0.5593 |
| 1 | Mr. Hi | 9 | 0.0574 | 0.3018 | 0.3333 | 0.0539 | 0.4853 |
| 31 | Officer | 6 | 0.0420 | 0.2095 | 0.2000 | 0.1383 | 0.5410 |
| 23 | Officer | 5 | 0.0411 | 0.2180 | 0.4000 | 0.0176 | 0.3929 |
| 3 | Mr. Hi | 6 | 0.0372 | 0.1986 | 0.6667 | 0.0119 | 0.4648 |
| 5 | Mr. Hi | 4 | 0.0338 | 0.0674 | 0.5000 | 0.0300 | 0.3837 |
| 13 | Mr. Hi | 5 | 0.0335 | 0.2405 | 0.6000 | 0.0459 | 0.5156 |
| 8 | Mr. Hi | 5 | 0.0334 | 0.2470 | 0.5000 | 0.0559 | 0.5156 |
| 6 | Mr. Hi | 4 | 0.0315 | 0.0664 | 0.5000 | 0.0300 | 0.3837 |
| 25 | Officer | 3 | 0.0287 | 0.1226 | 0.3333 | 0.0038 | 0.3750 |
| 29 | Officer | 4 | 0.0283 | 0.1358 | 0.6667 | 0.0029 | 0.3837 |
| 27 | Officer | 4 | 0.0272 | 0.1477 | 0.1667 | 0.0223 | 0.4583 |
| 7 | Mr. Hi | 4 | 0.0265 | 0.1784 | 1 | 0 | 0.4400 |
| 30 | Officer | 4 | 0.0230 | 0.1583 | 0.5000 | 0.0144 | 0.4583 |
| 10 | Mr. Hi | 3 | 0.0207 | 0.0458 | 0.6667 | 0.0006 | 0.3793 |
| 4 | Mr. Hi | 3 | 0.0205 | 0.0557 | 0.6667 | 0.0006 | 0.3793 |
| 16 | Mr. Hi | 2 | 0.0168 | 0.0185 | 1 | 0 | 0.2845 |
| 24 | Officer | 3 | 0.0166 | 0.0510 | 0.3333 | 0.0022 | 0.3750 |
| 15 | Officer | 2 | 0.0164 | 0.1131 | 1 | 0 | 0.3708 |
| 26 | Officer | 2 | 0.0152 | 0.0586 | 1 | 0 | 0.3626 |
| 28 | Officer | 3 | 0.0145 | 0.0861 | 0.3333 | 0.0018 | 0.4521 |
| 19 | Mr. Hi | 3 | 0.0131 | 0.0734 | 0.3333 | 0.0325 | 0.5000 |
Network checks
| Check | Count |
|---|---|
| Edge rows | 78 |
| Edge rows left out (missing source, target or weight) | 0 |
| Self-loops | 0 |
| Repeated edges merged | 0 |
| Isolated nodes | 0 |
| Separate parts | 1 |
| Node table rows | 34 |
| Node table rows left out | 0 |
| Nodes not in the node table | 0 |
| Node table nodes with no edges | 0 |
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Network description (size, degrees, clustering, centrality)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method describe.network 1.0.0 · spec 2393515369599210
# Dataset: graph_karate (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import numpy as np
import codesplash as cs
from codesplash import graph as cg
from codesplash.graph import describe as gd
from codesplash.graph import layout as gl
# %% Network
# The app read the edge list once and wrote the network next to this run (graph/ in the output folder):
# nodes in a fixed order, the edges, and the simple network (self-loops left out, repeated edges merged with
# their weights added). Python and R read the same files, so both describe the same network.
out_dir = "target/academy-parity/run-8142/describe.network/karate_club/out-python"
g = cg.read(out_dir)
warnings = list(g.warnings)
weighted = True and g.weighted
damping = 0.85
max_path_nodes = int(5000)
seed = 42
MAP_NODES = 2000 # largest network drawn as a map
MATRIX_NODES = 300 # largest network drawn as a matrix
PER_NODE = 200 # per-node values go into the result for networks up to this size
if weighted:
bad = int((g.edges["w"].to_numpy(dtype=float) <= 0).sum())
if bad:
cs.cs_error("CS_E_INVALID_VALUES", column="contexts", requirement="positive for weighted measures (or turn off Use weights)", count=bad)
n = g.n
m = len(g.si)
meta = g.meta
# %% Measures
# Degrees, density, reciprocity, clustering and assortativity, then one breadth-first search per node for
# betweenness, closeness and distances (Brandes 2001), then eigenvector centrality and PageRank by power
# iteration. Definitions follow networkx; the twins are codesplash.graph.describe and codesplashr.
deg = gd.degrees(g)
cl = gd.clustering(g)
pa = gd.paths(g, max_path_nodes)
ev = gd.eigenvector(g, weighted)
pr = gd.pagerank(g, damping, weighted)
comp = gd.components(g)
if not ev["converged"]:
warnings.append(cs.cs_warning("CS_W_NO_CONVERGENCE", what="Eigenvector centrality"))
if not pr["converged"]:
warnings.append(cs.cs_warning("CS_W_NO_CONVERGENCE", what="PageRank"))
if pa is None:
warnings.append(f"Betweenness, closeness and distances were skipped: the network has more than {max_path_nodes} nodes.")
def nn(x):
"""A finite number, or None."""
x = float(x)
return x if np.isfinite(x) else None
degree = deg["degree"]
centralization = None
if not g.directed and n > 2:
centralization = float((degree.max() - degree).sum()) / ((n - 1) * (n - 2))
values = {
"n_nodes": n,
"n_edges": m,
"n_edge_rows": int(meta["n_edges"]),
"density": nn(gd.density(g)),
"mean_degree": float(degree.mean()),
"median_degree": float(np.median(degree)),
"max_degree": int(degree.max()),
"max_in_degree": int(deg["in_degree"].max()) if g.directed else None,
"max_out_degree": int(deg["out_degree"].max()) if g.directed else None,
"reciprocity": nn(gd.reciprocity(g)) if g.directed else None,
"components": int(meta["components"]),
"largest_component": int(meta["largest_component"]),
"largest_share": int(meta["largest_component"]) / n,
"isolates": int(meta["isolates"]),
"self_loops": int(meta["self_loops"]),
"duplicate_edges": int(meta["duplicate_edges"]),
"triangles": cl["triangles"],
"transitivity": cl["transitivity"],
"avg_clustering": cl["average"],
"assortativity": nn(gd.assortativity(g)),
"degree_centralization": centralization,
"avg_path_length": nn(pa["avg_path_length"]) if pa else None,
"diameter": nn(pa["diameter"]) if pa else None,
"max_betweenness": float(pa["betweenness"].max()) if pa else None,
"max_closeness": float(pa["closeness"].max()) if pa else None,
"max_eigenvector": float(ev["x"].max()),
"max_pagerank": float(pr["x"].max()),
}
if n <= PER_NODE:
for k, node in enumerate(g.node_id):
values[f"degree[{node}]"] = int(degree[k])
if g.directed:
values[f"in_degree[{node}]"] = int(deg["in_degree"][k])
values[f"out_degree[{node}]"] = int(deg["out_degree"][k])
values[f"clustering[{node}]"] = float(cl["local"][k])
if pa:
values[f"betweenness[{node}]"] = float(pa["betweenness"][k])
values[f"closeness[{node}]"] = float(pa["closeness"][k])
values[f"eigenvector[{node}]"] = float(ev["x"][k])
values[f"pagerank[{node}]"] = float(pr["x"][k])
# %% Node table
# One row per node (node_id first); the app can save it as a dataset ("Save node table as dataset").
label = g.nodes[g.label].astype(object).where(g.nodes[g.label].notna(), None).tolist() if g.label else None
xy = gl.fruchterman_reingold(g, seed) if n <= MAP_NODES else None
cols = {}
if label is not None:
cols[g.label] = label
cols["component"] = comp + 1
cols["degree"] = degree
if g.directed:
cols["in_degree"] = deg["in_degree"]
cols["out_degree"] = deg["out_degree"]
if g.weighted:
if g.directed:
cols["in_strength"] = deg["in_strength"]
cols["out_strength"] = deg["out_strength"]
else:
cols["strength"] = deg["strength"]
cols["clustering"] = cl["local"]
if pa:
cols["betweenness"] = pa["betweenness"]
cols["closeness"] = pa["closeness"]
cols["eigenvector"] = ev["x"]
cols["pagerank"] = pr["x"]
if xy is not None:
cols["map_x"], cols["map_y"] = xy
artifact = cg.write_nodes(out_dir, g, cols)
# %% Tables
order = np.lexsort((np.arange(n), -pr["x"]))[:25]
node_cols = [{"key": "node", "label": "Node"}]
if label is not None:
node_cols.append({"key": "label", "label": g.label})
node_cols += [{"key": "degree", "label": "Degree", "type": "integer"}, {"key": "pagerank", "label": "PageRank", "type": "number"},
{"key": "eigenvector", "label": "Eigenvector", "type": "number"}, {"key": "clustering", "label": "Clustering", "type": "number"}]
if pa:
node_cols += [{"key": "betweenness", "label": "Betweenness", "type": "number"}, {"key": "closeness", "label": "Closeness", "type": "number"}]
rows = []
for k in order.tolist():
r = {"node": g.node_id[k], "degree": int(degree[k]), "pagerank": float(pr["x"][k]), "eigenvector": float(ev["x"][k]), "clustering": float(cl["local"][k])}
if label is not None:
r["label"] = None if label[k] is None else str(label[k])
if pa:
r["betweenness"] = float(pa["betweenness"][k])
r["closeness"] = float(pa["closeness"][k])
rows.append(r)
checks = [
("Edge rows", int(meta["input_rows"])),
("Edge rows left out (missing source, target or weight)", int(meta["dropped_rows"])),
("Self-loops", int(meta["self_loops"])),
("Repeated edges merged", int(meta["duplicate_edges"])),
("Isolated nodes", int(meta["isolates"])),
("Separate parts", int(meta["components"])),
]
nt = meta.get("node_table")
if nt:
checks += [("Node table rows", int(nt["rows"])), ("Node table rows left out", int(nt["dropped_rows"])),
("Nodes not in the node table", int(nt["missing_ids"])), ("Node table nodes with no edges", int(nt["extra_ids"]))]
tables = [
{"key": "top_nodes", "title": "Most central nodes (by PageRank)", "columns": node_cols, "rows": rows},
{"key": "checks", "title": "Network checks", "columns": [{"key": "check", "label": "Check"}, {"key": "count", "label": "Count", "type": "integer"}],
"rows": [{"check": c, "count": k} for c, k in checks]},
]
# %% Charts
def padded(values, rows):
"""Node and edge columns share one chart table: shorter columns end in empty cells."""
vals = list(values.tolist() if hasattr(values, "tolist") else values)
return vals + [None] * (rows - len(vals))
group = [("(missing)" if v is None else str(v)) for v in label] if label is not None else [f"part {c + 1}" for c in comp]
group_title = g.label if label is not None else "Part"
charts = []
if xy is not None:
show = min(m, 20000)
rows_map = max(n, show)
charts.append(cs.chart("map", "network-graph", "Network map", {
"x": cs.col("x", padded(xy[0], rows_map), "numeric"),
"y": cs.col("y", padded(xy[1], rows_map), "numeric"),
"node": cs.col("Node", padded(g.node_id, rows_map), "categorical"),
"size": cs.col("Degree", padded(degree, rows_map), "numeric"),
"group": cs.col(group_title, padded(group, rows_map), "categorical"),
"from": cs.col("From", padded(g.si[:show], rows_map), "numeric"),
"to": cs.col("To", padded(g.sj[:show], rows_map), "numeric"),
"weight": cs.col("Weight", padded(g.sw[:show], rows_map), "numeric") if g.weighted else None,
}, controls={"directed": g.directed}, note=None if show == m else f"{show} of {m} edges drawn."))
else:
charts.append(cs.chart("map", "network-graph", "Network map", {}, note=f"The map is drawn for networks up to {MAP_NODES} nodes; this one has {n}."))
if g.directed:
k_in, p_in = gd.degree_ccdf(deg["in_degree"])
k_out, p_out = gd.degree_ccdf(deg["out_degree"])
ks, ps, series = list(k_in) + list(k_out), list(p_in) + list(p_out), ["In-degree"] * len(k_in) + ["Out-degree"] * len(k_out)
series_levels = ["In-degree", "Out-degree"]
else:
k_all, p_all = gd.degree_ccdf(degree)
ks, ps, series, series_levels = list(k_all), list(p_all), ["Degree"] * len(k_all), ["Degree"]
charts.append(cs.chart("degrees", "degree-ccdf", "Degree distribution", {
"degree": cs.col("Degree k", ks, "numeric"),
"share": cs.col("Share of nodes with degree ≥ k", ps, "numeric"),
"series": cs.col("Degree", series, "categorical", series_levels),
}))
if n <= MATRIX_NODES:
morder = sorted(range(n), key=lambda k: (group[k] == "(missing)", group[k], -int(degree[k]), k))
rows_mx = max(n, m)
charts.append(cs.chart("matrix", "adjacency-matrix", "Adjacency matrix", {
"row": cs.col("Row", padded(g.si, rows_mx), "numeric"),
"col": cs.col("Column", padded(g.sj, rows_mx), "numeric"),
"value": cs.col("Weight" if g.weighted else "Edge", padded(g.sw, rows_mx), "numeric"),
"node": cs.col("Node", padded(g.node_id, rows_mx), "categorical"),
"group": cs.col(group_title, padded(group, rows_mx), "categorical"),
"order": cs.col("Order", padded(morder, rows_mx), "numeric"),
}, controls={"directed": g.directed}))
# %% Result
kind = "directed" if g.directed else "undirected"
dens = "undefined" if values["density"] is None else f"{values['density']:.3f}"
summary = f"A {kind} network of {n} nodes and {m} edges (density {dens}); {values['components']} part(s), the largest with {values['largest_component']} nodes."
cs.publish({
"title": "Network description (size, degrees, clustering, centrality)",
"engine": cs.engine_info("numpy", "pandas"),
"n": n,
"summary": summary,
"statistics": [
{"key": "n_nodes", "label": "Nodes", "value": n, "format": "integer"},
{"key": "n_edges", "label": "Edges", "value": m, "format": "integer"},
{"key": "density", "label": "Density", "value": values["density"]},
{"key": "components", "label": "Separate parts", "value": values["components"], "format": "integer"},
{"key": "transitivity", "label": "Transitivity", "value": values["transitivity"]},
{"key": "assortativity", "label": "Degree assortativity", "value": values["assortativity"]},
],
"tables": tables,
"values": values,
"charts": charts,
"warnings": warnings,
"artifacts": [artifact],
})
Each centrality answers a different question:
- Degree: how many ties a node has.
- BetweennessBetweenness centralityShare of shortest paths between other pairs that pass through a node (0 to 1): high for brokers between groups.: how many shortest paths between others pass through it. Brokers between groups score high.
- Closeness: how few steps it takes to reach everyone else.
- Eigenvector and PageRankPageRankShare of time a random walker spends at a node, following edges or jumping anywhere; sums to 1 over all nodes.: a node matters when its neighbors matter.
Check yourself
A member has only four friends but the highest betweenness in the club. What's the most likely reason?
Show the answer
Answer: b
Betweenness counts shortest paths through a node, in steps, not weights. A broker between two groups can have few ties and still hold the network together.
Blocks and hubs
ExploreView data
| from | to | messages | person | department |
|---|---|---|---|---|
| 0 | 4 | 5 | Fin-1 | Finance |
| 0 | 5 | 7 | Fin-2 | Finance |
| 0 | 7 | 6 | Fin-3 | Finance |
| 0 | 11 | 5 | Fin-4 | Finance |
| 0 | 20 | 6 | Fin-5 | Finance |
| 1 | 3 | 8 | Fin-6 | Finance |
| 1 | 4 | 1 | Fin-7 | Finance |
| 1 | 5 | 7 | Fin-8 | Finance |
| 1 | 13 | 9 | Ope-1 | Operations |
| 2 | 3 | 3 | Ope-2 | Operations |
| 2 | 4 | 3 | Ope-3 | Operations |
| 2 | 6 | 3 | Ope-4 | Operations |
| 2 | 7 | 6 | Ope-5 | Operations |
| 2 | 15 | 1 | Ope-6 | Operations |
| 3 | 5 | 7 | Ope-7 | Operations |
| 4 | 5 | 2 | Ope-8 | Operations |
| 4 | 12 | 4 | Res-1 | Research |
| 4 | 17 | 5 | Res-2 | Research |
| 4 | 21 | 6 | Res-3 | Research |
| 5 | 7 | 4 | Res-4 | Research |
| 6 | 8 | 4 | Res-5 | Research |
| 7 | 11 | 7 | Res-6 | Research |
| 7 | 15 | 9 | Res-7 | Research |
| 8 | 11 | 1 | Res-8 | Research |
| 8 | 12 | 8 | — | — |
| 8 | 13 | 7 | — | — |
| 8 | 14 | 1 | — | — |
| 9 | 11 | 8 | — | — |
| 9 | 12 | 3 | — | — |
| 9 | 14 | 6 | — | — |
| 10 | 14 | 1 | — | — |
| 11 | 15 | 9 | — | — |
| 13 | 15 | 9 | — | — |
| 14 | 15 | 3 | — | — |
| 16 | 20 | 1 | — | — |
| 17 | 19 | 3 | — | — |
| 17 | 22 | 6 | — | — |
| 17 | 23 | 2 | — | — |
| 18 | 19 | 3 | — | — |
| 18 | 20 | 5 | — | — |
| 18 | 21 | 2 | — | — |
| 18 | 22 | 4 | — | — |
| 18 | 23 | 9 | — | — |
| 19 | 23 | 4 | — | — |
| 20 | 22 | 1 | — | — |
| 21 | 22 | 6 | — | — |
| 22 | 23 | 2 | — | — |
Sorted by group, tightly knit groups show as dark blocks on the diagonal. Ties between groups sit off it.
View data
| degree k | share of nodes with degree ≥ k | degree |
|---|---|---|
| 1 | 0.8600 | In-degree |
| 2 | 0.6450 | In-degree |
| 3 | 0.5175 | In-degree |
| 4 | 0.4300 | In-degree |
| 5 | 0.3525 | In-degree |
| 6 | 0.3000 | In-degree |
| 7 | 0.2625 | In-degree |
| 8 | 0.2225 | In-degree |
| 9 | 0.2050 | In-degree |
| 10 | 0.1800 | In-degree |
| 11 | 0.1575 | In-degree |
| 12 | 0.1400 | In-degree |
| 13 | 0.1200 | In-degree |
| 14 | 0.1025 | In-degree |
| 15 | 0.0975 | In-degree |
| 16 | 0.0900 | In-degree |
| 17 | 0.0850 | In-degree |
| 18 | 0.0750 | In-degree |
| 19 | 0.0700 | In-degree |
| 20 | 0.0650 | In-degree |
| 21 | 0.0550 | In-degree |
| 23 | 0.0475 | In-degree |
| 25 | 0.0450 | In-degree |
| 26 | 0.0425 | In-degree |
| 27 | 0.0350 | In-degree |
| 28 | 0.0325 | In-degree |
| 29 | 0.0275 | In-degree |
| 31 | 0.0250 | In-degree |
| 34 | 0.0225 | In-degree |
| 36 | 0.0200 | In-degree |
| 38 | 0.0175 | In-degree |
| 43 | 0.0150 | In-degree |
| 64 | 0.0125 | In-degree |
| 65 | 0.0075 | In-degree |
| 67 | 0.0050 | In-degree |
| 70 | 0.0025 | In-degree |
| 1 | 0.9500 | Out-degree |
| 2 | 0.9025 | Out-degree |
| 3 | 0.7675 | Out-degree |
| 4 | 0.5875 | Out-degree |
| 5 | 0.3700 | Out-degree |
| 6 | 0.2125 | Out-degree |
| 7 | 0.1100 | Out-degree |
| 8 | 0.0425 | Out-degree |
| 9 | 0.0125 | Out-degree |
The degree curve shows the share of nodes with at least k ties. On log–log axes a long, slowly falling tail means a few hubs hold many ties.
Checks and node tables
CheckpointA test network of three teams has a self-loop, a repeated edge, a row with no target, and a node table that misses one person and adds one with no ties. The card's Network checks table counts each, and the warnings say what was done: 1 isolated node, 1 self-loop left out, 1 repeated edge merged.
Check yourself
Why does the app save node results as a new dataset instead of adding them as columns to the edge list?
Show the answer
Answer: b
Node measures belong to nodes. Save node table as dataset keeps one row per node, ready to join to the node table or chart.
Do it on your own data
In the appOpen Discover → Networks and choose a dataset with one row per tie. When two columns are named like an edge list (From and To, source and target, sender and receiver), the method opens with them bound. Add a node table under Node table in the setup.
from codesplash import graph as cg
from codesplash.graph import describe as gd
g = cg.read("out") # the app writes out/graph/ next to the run
print(gd.density(g), gd.clustering(g)["transitivity"], gd.assortativity(g))
print(gd.pagerank(g, 0.85)["x"][:5]) # one value per node, in g.node_id orderlibrary(codesplashr)
g <- cs_graph_read("out")
c(cs_graph_density(g), cs_graph_clustering(g)$transitivity, cs_graph_assortativity(g))
head(cs_graph_pagerank(g, 0.85)$x)Recap
Recap- An edge list has one row per tie; the app checks it once and both engines read the same network.
- Density, separate parts, clustering and assortativity describe the whole network; centralities rank the nodes.
- Betweenness and closeness count steps; eigenvector centrality and PageRank can use weights.
- Node results become a dataset of their own, never columns of the edge list.
Concepts in this lesson