Assortativity, transitivity, reciprocity and similarity
Short, exam-focused notes on how degree assortativity, transitivity (clustering), reciprocity and node similarity are defined, measured, derived and computed on small graphs, with worked exam-style examples.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Engineers use these measures to describe and compare network structure, to predict diffusion, recommend links, detect communities or anomalies, and to design or evaluate algorithms that use network topology (for example link prediction, influence maximisation and community detection). Knowing when a network is assortative, highly clustered, reciprocal or when node pairs are similar helps pick models (see "Preferential attachment and growth models", "Link prediction") and affects performance of distributed algorithms.
Key ideas
Start with simple definitions. Each bold term is defined before use.
Graph / network: a set of nodes (vertices) and edges (ties). Edges can be undirected or directed. We assume simple graphs (no self-loops, no parallel edges) unless stated.
Degree (deg(v)): for an undirected node v, the number of incident edges. For a directed node, out-degree is the number of outgoing edges and in-degree is the number of incoming edges.
Edge list representation: list edges (u,v). For undirected graphs treat (u,v) = (v,u) once.
Triangle: three nodes all connected pairwise by edges (a 3-cycle).
Connected triple: three nodes where two edges share a common middle node j (i.e., an unordered pair of neighbours of j). The ends i and k may or may not be connected; if they are, the triple is closed (forms a triangle). A triple is centred on the middle node j.
Transitivity / Global clustering coefficient: the fraction of connected triples that are closed (i.e., form triangles). Exact definition used in many exams:
- Let T be the number of triangles (each triangle counts once).
- Let Σ_triples be the number of connected triples (each triple counted once).
- Global clustering coefficient C = 3·T / Σ_triples. The factor 3 appears because each triangle contains three connected triples.
Assumptions: simple undirected graph; triangles counted once; triples counted centred on middle node.
Local clustering coefficient for node v: the fraction of pairs among v's neighbours that are connected. Note: the global clustering (transitivity) and the average of local clustering coefficients are different quantities; exams may ask for either, so state which one you compute. If deg(v) < 2 we conventionally set local clustering to 0 or define it undefined (exams usually say set to 0). Exact formula:
- Lv = number of edges between neighbours of v.
- Local C_v = (2·Lv) / (deg(v)·(deg(v)-1)).
Assortativity (degree assortativity): measures tendency of nodes to connect to others with similar degree. The standard measure (Newman) is the Pearson correlation coefficient of the degrees at the two ends of an edge. For an undirected simple graph with M edges label edges i=1..M and let (j_i,k_i) be degrees at the two ends of edge i. One common form used in exams is:
r = [ (1/M) Σ_i (j_i·k_i) - μ^2 ] / [ (1/M) Σ_i ( (j_i^2 + k_i^2)/2 ) - μ^2 ],
where μ = (1/M) Σ_i ( (j_i + k_i)/2 ).
Assumptions: undirected simple graph; each edge counted once. r ∈ [-1,1]: r>0 assortative, r<0 disassortative, r≈0 no correlation. For directed graphs you can define assortativity between in-/out-degrees in four pairings (in–in, out–out, in–out, out–in); state which pairing you use.
(There is an equivalent derivation using the joint distribution of remaining degrees and the standard Pearson correlation formula; many university answers derive the formula by starting with Pearson correlation over edge-ends and simplifying to the above symmetric form.)
Reciprocity (for directed graphs): a measure of two-way ties. A simple, common exam definition:
- Let L be the total number of directed edges (arcs).
- Let L↔ be the number of mutual pairs (pairs of nodes u,v such that both u→v and v→u exist); count each mutual pair once.
- Reciprocity r = 2·L↔ / L.
This r is in [0,1] and equals the fraction of directed edges that are part of mutual pairs (i.e., reciprocated). Note: some texts use alternative normalisations (e.g., fraction of reciprocated dyads or Pearson-like measures). State which you use in an answer.
Similarity between nodes: measures based on neighbours or attributes. Two common neighbour-based measures are:
- Jaccard index for nodes u,v: J(u,v) = |N(u) ∩ N(v)| / |N(u) ∪ N(v)|. Unitless, between 0 and 1.
- Cosine similarity (on binary neighbour vectors): cos(u,v) = |N(u) ∩ N(v)| / sqrt(|N(u)|·|N(v)|).
Use these in link prediction and recommendation tasks (see "Link prediction" in the course list).
Diagrams to draw in exam answers:
- For transitivity: draw three nodes A–B–C with edges A–B and B–C (an open triple). Then draw the triangle A–B–C closed triple. Label nodes A,B,C and mark the middle node of the triple (B) and indicate a closed vs open triple.
- For assortativity: draw a small graph with degrees labelled at each node and show how you form the (j_i,k_i) pairs for each edge, then a small table with columns edge, j, k, j·k, (j^2+k^2)/2.
Formulas
C = 3·T / N_triples — C is the global clustering (transitivity), T = number of triangles, N_triples = number of connected triples. Unitless; applies to simple undirected graphs.
C_v = (2·L_v) / (deg(v)·(deg(v)-1)) — local clustering of node v; L_v = edges among neighbours of v. Unitless; deg(v) must be ≥ 2 (else set to 0 by convention).
r = [ (1/M) Σ_i (j_i·k_i) - μ^2 ] / [ (1/M) Σ_i ( (j_i^2 + k_i^2)/2 ) - μ^2 ] — degree assortativity r for undirected graph, M = number of edges, edge i has end-degrees j_i and k_i, μ = (1/M) Σ_i ( (j_i + k_i)/2 ). Unitless; applies to undirected simple graphs.
r_rec = 2·L↔ / L — simple reciprocity for directed graphs, L↔ = number of mutual node pairs (each contributes two reciprocated edges), L = total directed edges. Unitless.
J(u,v) = |N(u) ∩ N(v)| / |N(u) ∪ N(v)| — Jaccard similarity. Unitless.
cos(u,v) = |N(u) ∩ N(v)| / sqrt(|N(u)|·|N(v)|) — Cosine similarity on binary neighbour vectors. Unitless.
Worked examples
Example 1 — undirected graph: compute transitivity, local clustering and degree assortativity
Graph G with nodes A,B,C,D,E and edges: AB, AC, BC, BD, BE, DE. (Draw five nodes and label edges accordingly.)
Step 1: degrees
- deg(A)=2 (B,C)
- deg(B)=4 (A,C,D,E)
- deg(C)=2 (A,B)
- deg(D)=2 (B,E)
- deg(E)=2 (B,D)
Step 2: triangles and connected triples
- Triangles T: A-B-C and B-D-E ⇒ T = 2.
- Connected triples: sum over nodes of C(deg(v),2) = A:1, B:6, C:1, D:1, E:1 ⇒ N_triples = 10.
- Global clustering C = 3·T / N_triples = 3·2 / 10 = 6/10 = 0.6.
Step 3: local clustering
- For A: neighbours {B,C} connected ⇒ C_A = 1/1 = 1.
- For B: neighbours {A,C,D,E} have edges (A-C) and (D-E) ⇒ L_B = 2 ⇒ C_B = (2·2)/(4·3) = 4/12 = 1/3 ≈ 0.3333.
- For C,D,E: each like A (deg 2 with neighbours connected) ⇒ C_C = C_D = C_E = 1.
- Average local clustering = (1 + 1/3 + 1 + 1 + 1)/5 = 4 1/3 /5 = 0.866666... ≈ 0.8667.
Step 4: assortativity r (edge list method)
- M = 6 edges. For each edge list (j,k) degrees at ends: AB (2,4), AC (2,2), BC (4,2), BD (4,2), BE (4,2), DE (2,2).
- Compute Σ(j·k) = 8 + 4 + 8 + 8 + 8 + 4 = 40. So (1/M)Σ(j·k) = 40/6 ≈ 6.6667.
- Compute Σ((j^2+k^2)/2): first Σ(j^2+k^2) = 96 ⇒ (1/M)·((1/2)Σ(j^2+k^2)) = 96/(12) = 8.
- μ = (1/M) Σ((j+k)/2) = Σ(j+k)/(2M) = 32/12 = 8/3 ≈ 2.6667; μ^2 = 64/9 ≈ 7.1111.
- Numerator = 6.6667 - 7.1111 = -0.4444. Denominator = 8 - 7.1111 = 0.8889.
- r = -0.4444 / 0.8889 = -0.5. Final: r = -0.5 (disassortative).
(Interpretation: high-degree node B is mostly connected to degree-2 nodes, producing negative degree correlation.)
Example 2 — reciprocity and similarity on a tiny directed graph
Directed edges: X→Y, Y→X, X→Z, Z→Y. Draw three nodes X,Y,Z and arrows accordingly.
- L = 4 directed edges.
- Mutually connected pairs: {X,Y} is mutual (X→Y and Y→X) ⇒ L↔ = 1.
- Reciprocity r = 2·L↔ / L = 2/4 = 0.5.
Similarity (use the undirected graph from Example 1): compute similarity of A and D using neighbour sets
- N(A) = {B,C}, N(D) = {B,E}.
- |N(A) ∩ N(D)| = 1 (node B). |N(A) ∪ N(D)| = 3 (B,C,E).
- Jaccard J(A,D) = 1/3 ≈ 0.3333.
- Cosine cos(A,D) = 1 / sqrt(2·2) = 1/2 = 0.5.
Example 3 — short model answer (theory question)
Question: Explain the difference between transitivity and assortativity and give one practical consequence of each.
Model answer (exam style):
- Transitivity (global clustering) measures the tendency for two nodes with a common neighbour to be connected; it counts triangles relative to connected triples. A high transitivity means strong local cohesion and many short cycles; practical consequence: processes that require local reinforcement (e.g., trust propagation, information redundancy) operate faster in highly transitive networks.
- Assortativity measures correlation between node degrees at the ends of edges; it is a Pearson correlation over edge-ends. Positive assortativity means high-degree nodes link to high-degree nodes, which affects network robustness: assortative networks are more robust to random failures but may fragment differently under targeted attacks. State sign and formula and give an example.
(Full marks answer gives precise definitions, the formula used, sign interpretation, and one concrete application.)
Common mistakes
- Using degrees of nodes rather than remaining-degree when deriving alternative forms of assortativity (remaining-degree = degree-1), or not stating assumptions (simple/undirected).
- Forgetting to set local clustering to 0 for nodes with degree < 2 when computing averages if the exam requires that convention.
- For assortativity, failing to use edge-based sums (j_i,k_i) and instead summing over nodes incorrectly.
- In similarity, not excluding the nodes themselves or mixing attribute similarity with neighbour-set similarity without stating it.
For your exam
Typical question types:
- Definitions and short notes: give precise definitions and interpretations of assortativity, transitivity, reciprocity, similarity.
- Derivation: derive the edge-sum formula for assortativity from Pearson correlation (state assumptions) or show relation between triangles and triples for transitivity.
- Numericals: compute C, local clustering, r (assortativity) on a given small graph (draw and label degrees and edge table). Show all sums and intermediate numbers.
- Diagrams: draw an open triple and a closed triangle and label how triples are counted; draw an example graph and show edge-end degree pairs for assortativity.
What full-marks answers include:
- Exact definition with symbols. Clear statement of assumptions (directed/undirected, simple graph). Correct formulas and every algebraic step in derivations. Complete calculations with M, Σ(j·k), Σ(j+k), Σ(j^2+k^2), final numeric value with sign interpretation. For reciprocity, state which normalisation you use.
Quick check
- What is the global clustering coefficient if a graph has 3 triangles and 30 connected triples?
- If an undirected edge connects degrees 1 and 5 and another connects 2 and 4, write the pairs (j_i,k_i) and compute their products and the mean μ of (j+k)/2 for these two edges.
- For N(u)={A,B,C} and N(v)={B,C,D,E}, what are the Jaccard and cosine similarities?
Answers: 1) 3·3/30 = 9/30 = 0.3. 2) pairs (1,5) and (2,4); products 5 and 8; μ = ((1+5)/2 + (2+4)/2)/2 = (3 + 3)/2 = 3. 3) Intersection size =2, union size =5 ⇒ Jaccard = 2/5 = 0.4; cosine = 2 / sqrt(3·4) = 2 / sqrt(12) = 2 / (2·sqrt(3)) = 1/√3 ≈ 0.5774.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?