Chapter 24 · Graph Algorithms: Centrality, Community Detection, Similarity, Paths, and Topology Analytics
Degree, PageRank, Betweenness, Eigenvector-Like Centrality Concepts and Business Interpretation
Compare Degree, PageRank, Betweenness, and Eigenvector Centrality on a bounded AtlasMart product graph, validate direct-degree structure manually, and interpret structural importance without business overclaiming.
Learning outcomes
Distinguish Degree, PageRank, Betweenness, and Eigenvector Centrality by the structural question each answers.
Explain how direction, relationship weight, damping, shortest-path assumptions, and iteration change centrality semantics.
Run memory estimates and stream-mode algorithms on a bounded AtlasMart projection without persisting scores.
Validate one centrality result manually and separate structural importance from business value or causation.
Choose a production interpretation only after documenting graph scope, refresh cadence, cost, and uncertainty.
1. AtlasMart problem: “important product” is not one mathematical question
AtlasMart merchandising asks for “the most important products” in a product-to-product interaction network. That sentence is underspecified. A product with many direct connections is different from one pointed to by already-influential products; a bridge between otherwise separate product groups is different again. GDS centrality algorithms are structural measurements over a chosen projection, not universal business-value scores.
The mechanism-first rule is: state the decision question, define the projected edge semantics, then choose the centrality family. If the projection says “customers often viewed these products in the same session,” a centrality score is evidence about that interaction topology. It does not prove margin, causal influence, future demand, or merchandising quality.
| Dimension | Chapter 24 reproducible assumption |
|---|---|
| Neo4j |
2026.07.1 Community, disposable local/container
deployment; database neo4j.
|
| Cypher | Cypher 25 for course examples; Cypher 5 differences are not needed for the GDS procedures used here. |
| Java | Java 21/25 supported by the 2026 line; container image supplies the runtime. |
| Auth/TLS |
User neo4j, password
atlasmart-course-2026; loopback Bolt without
TLS only for this isolated lab.
|
| Driver | No application driver is required for mandatory GDS procedure labs; cypher-shell/Browser is sufficient. |
| GDS | GDS Community 2026.07.0. Community includes all algorithms; maximum GDS concurrency is four CPU cores. |
| APOC | Not required. |
| Graph scope |
Only identifiers prefixed CH24- plus named
in-memory projections beginning
atlas-ch24- are created.
|
| Runtime evidence | This artifact does not execute Neo4j/GDS. Exact fixture counts and hand calculations are deterministic; timings, memory estimates, and algorithm scores must be measured locally. |
// Run in the disposable atlasmart-gds lab from Chapter 23.
RETURN gds.version() AS gdsVersion;
CALL dbms.components() YIELD name, versions, edition
RETURN name, versions, edition;
// Defensive cleanup of Chapter 24 projections if rerunning.
CALL gds.graph.list()
YIELD graphName
WITH graphName WHERE graphName STARTS WITH 'atlas-ch24-'
CALL gds.graph.drop(graphName) YIELD graphName AS dropped
RETURN dropped;
2. Four centrality questions, four mechanisms
| Algorithm | Question answered | Mechanism | Key boundary |
|---|---|---|---|
| Degree | Who has many direct connections? | Counts incident/outgoing/incoming relationships according to projection/orientation; weighted Degree can sum valid relationship weights. | Local only; no notion of distant influence. |
| PageRank | Who receives importance from important neighbors? | Iterative score propagation with damping/jump behavior; weighted mode redistributes score according to outgoing weight proportions. | Direction and dangling structure matter; score is not a probability of purchase. |
| Betweenness | Who lies on many shortest paths? | Counts how often nodes occur on shortest paths; GDS can sample source nodes to approximate expensive all-pairs work. | Meaning depends on shortest-path metric and graph scope. |
| Eigenvector Centrality | Who is connected to already-high-scoring neighbors? | Power iteration finds the dominant eigenvector; incoming-neighbor scores reinforce one another. | High degree can dominate because there is no degree normalization like PageRank. |
“Eigenvector-like” is useful language when explaining the
family, but GDS now exposes a concrete production-quality
gds.eigenvector.* algorithm. PageRank is related
but adds jump/damping behavior, so the two should not be treated
as aliases.
3. Build a hand-checkable product graph
The fixture below creates six synthetic products and seven
RELATED_TO edges. The edge is explicitly an
analytics-only “co-interest” relation derived for this lesson,
not an order-line fact. strength means non-negative
interaction strength; cost is not used by
centrality here.
MATCH (n) WHERE n.chapter24 = true DETACH DELETE n;
UNWIND [
['CH24-P-A','Camera Hub'], ['CH24-P-B','Lens Basic'],
['CH24-P-C','Tripod'], ['CH24-P-D','Creator Kit'],
['CH24-P-E','Light'], ['CH24-P-F','Mic']
] AS row
MERGE (p:Product:CH24CentralityProduct {productId: row[0]})
SET p.name = row[1], p.chapter24 = true;
MATCH (a:Product {productId:'CH24-P-A'}), (b:Product {productId:'CH24-P-B'}),
(c:Product {productId:'CH24-P-C'}), (d:Product {productId:'CH24-P-D'}),
(e:Product {productId:'CH24-P-E'}), (f:Product {productId:'CH24-P-F'})
CREATE (a)-[:RELATED_TO {strength:4.0}]->(b),
(a)-[:RELATED_TO {strength:3.0}]->(c),
(b)-[:RELATED_TO {strength:2.0}]->(d),
(c)-[:RELATED_TO {strength:2.0}]->(d),
(d)-[:RELATED_TO {strength:3.0}]->(e),
(d)-[:RELATED_TO {strength:3.0}]->(f),
(e)-[:RELATED_TO {strength:1.0}]->(f);
MATCH (p:Product) WHERE p.chapter24 = true
RETURN p.productId, p.name ORDER BY p.productId;
Deterministic invariant: there are six Chapter-24 Product nodes
and seven Chapter-24 RELATED_TO relationships. That
is fixture evidence, not a measured algorithm result.
4. Project only what the question needs, then estimate
CALL gds.graph.project(
'atlas-ch24-centrality',
'CH24CentralityProduct',
{RELATED_TO: {properties: ['strength']}}
)
YIELD graphName, nodeCount, relationshipCount;
CALL gds.pageRank.stream.estimate('atlas-ch24-centrality', {concurrency: 2})
YIELD nodeCount, relationshipCount, bytesMin, bytesMax, requiredMemory
RETURN *;
CALL gds.betweenness.stream.estimate('atlas-ch24-centrality', {concurrency: 2})
YIELD nodeCount, relationshipCount, bytesMin, bytesMax, requiredMemory
RETURN *;
requiredMemory depends on the installed GDS build
and projection. Record the local result. The only
deterministic checks here are graph scope and fixture
cardinality.
5. Run Degree first because it is manually falsifiable
// Local direct-connectivity baseline.
CALL gds.degree.stream('atlas-ch24-centrality')
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).productId AS productId, score
ORDER BY score DESC, productId;
// Transitive influence with explicit configuration.
CALL gds.pageRank.stream('atlas-ch24-centrality', {
maxIterations: 20,
dampingFactor: 0.85,
concurrency: 2
}) YIELD nodeId, score
RETURN gds.util.asNode(nodeId).productId AS productId, score
ORDER BY score DESC, productId;
// Exact on this tiny graph because samplingSize is omitted (defaults to node count).
CALL gds.betweenness.stream('atlas-ch24-centrality', {concurrency: 2})
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).productId AS productId, score
ORDER BY score DESC, productId;
CALL gds.eigenvector.stream('atlas-ch24-centrality', {
maxIterations: 20,
tolerance: 0.000001,
concurrency: 2
}) YIELD nodeId, score
RETURN gds.util.asNode(nodeId).productId AS productId, score
ORDER BY score DESC, productId;
Manual Degree baseline: with NATURAL orientation, A has two
outgoing RELATED_TO edges, D has two, B/C/E have
one, and F has zero. If your Degree result does not reflect the
orientation/configuration you intended, investigate the
projection before interpreting any more sophisticated score.
6. Weights are semantics, not a free “accuracy” switch
For PageRank,
relationshipWeightProperty:'strength' changes how a
node distributes its score across outgoing relationships. For
Betweenness, a weight is interpreted as shortest-path cost; a
large “strength” therefore has the opposite direction from a
typical distance/cost interpretation. Reusing
strength as a path cost would be semantically wrong
even if the procedure accepts the property.
| Property idea | Valid for PageRank? | Valid for weighted shortest-path centrality? | Reason |
|---|---|---|---|
strength=4 means stronger co-interest
|
Often reasonable after validation | Usually no | High strength should normally make a connection stronger, while path cost normally grows with distance/cost. |
minutes=4 means travel time |
Rarely meaningful | Yes, if non-negative | Additive positive cost has a clear shortest-path interpretation. |
profit=-5 |
Unsafe/ambiguous | No | Negative values violate several path/weight assumptions; PageRank also ignores negative relationship weights. |
7. Deliberately wrong: choose PageRank because everyone has heard of it
The wrong approach is to run PageRank, sort descending, and call the top product “most valuable.” The concrete defect is a semantic mismatch: PageRank measures graph influence under its score-propagation assumptions, while “valuable” could mean contribution margin, conversion lift, strategic dependency, or customer retention.
The repair is to write an interpretation contract: projection source, edge meaning, direction, weighting, algorithm/configuration, refresh timestamp, and the decision for which the score is only one input. Verify against a simple baseline (Degree), known fixtures, and downstream business evidence rather than renaming a structural score.
Production judgment and bridge
| Decision surface | Evidence to collect before production use |
|---|---|
| Algorithm fit | Why direct degree, transitive influence, or shortest-path brokerage matches the stated decision. |
| Sensitivity | Ranking changes under direction/weight/damping/sampling changes. |
| Cost | Projection memory + algorithm estimate + measured compute time and concurrency on production-like density. |
| Freshness | How often the projection is rebuilt and whether stale scores are acceptable. |
| Correctness boundary | Structural association only; no causal or profit claim without independent evidence. |
| Operations | GDS Community four-core ceiling, workload isolation, cleanup, backup of source data—not the assumption that an in-memory projection is durable. |
Next, the question changes from “which node is structurally central?” to “which nodes form a structurally dense group?” That requires community-detection assumptions and stability checks rather than centrality ranks.
Check your understanding
- Why can PageRank and Eigenvector Centrality rank the same graph differently?
- What makes the Degree fixture manually useful?
- When is sampled Betweenness approximate?
- Why is “strength” not automatically a valid shortest-path weight?
- What does a high centrality score prove about profit?
Review the answers
1. PageRank adds damping/jump behavior and degree-normalized score propagation; Eigenvector Centrality reinforces incoming influence without the same normalization/jump semantics.
2. Its expected outgoing degree counts follow directly from seven explicitly created edges, so it can detect a projection/orientation mistake before complex interpretation.
3. When samplingSize is
smaller than the node count; use a fixed
samplingSeed to make the sample reproducible.
4. Shortest-path weights are additive costs/distances. Larger strength often means stronger/closer, which inverts that semantic.
5. Nothing by itself. It proves only the algorithm-defined structural property on the exact projected graph/configuration.
// Drop all Chapter 24 in-memory projections first.
CALL gds.graph.list()
YIELD graphName
WITH graphName WHERE graphName STARTS WITH 'atlas-ch24-'
CALL gds.graph.drop(graphName) YIELD graphName AS dropped
RETURN dropped;
// Then delete only synthetic Chapter 24 persisted fixtures.
MATCH (n)
WHERE n.chapter24 = true
DETACH DELETE n;
MATCH (n) WHERE n.chapter24 IS NOT NULL REMOVE n.chapter24;
RETURN 'Chapter 24 reset complete' AS status;
Summary and next step
Degree, PageRank, Betweenness, Eigenvector-Like Centrality Concepts and Business Interpretation is useful only when its assumptions and observed evidence stay attached to the decision. The examples above establish a reproducible mechanism and boundary; they do not turn one lab result into a universal production rule.
Next, continue to Louvain/Leiden/Label Propagation and Community Detection: Resolution, Stability, and Validation. Carry forward the verified assumptions, fixture state, version/edition boundaries, and measurements from this lesson instead of treating the next topic as an isolated recipe.
Authoritative references
- GDS Manual v2026.07 — Current Graph Data Science manual and release baseline.
- GDS supported Neo4j versions — Compatibility matrix mapping Neo4j 2026.07 to GDS 2026.07.
- GDS editions — Community includes all algorithms but caps concurrency at four CPU cores and the model catalog at three models; Enterprise adds operational capabilities.
- Algorithm syntax and execution modes — stream/stats/mutate/write/estimate semantics and common algorithm configuration.
- Memory estimation — Estimate memory before allocating algorithm working state.
- Centrality algorithms — Current centrality family and quality tiers.
- Degree Centrality — Degree semantics and weighted/directed behavior.
- PageRank — PageRank iteration, damping, weights, and execution modes.
- Betweenness Centrality — Exact/sampled betweenness, samplingSize/samplingSeed, memory and concurrency tradeoffs.
- Eigenvector Centrality — Transitive influence and power-iteration semantics.
- Louvain — Modularity, levels, tolerance, seeding and execution modes.
- Leiden — Community detection with gamma, theta, randomSeed and connectivity refinement.
- Label Propagation — Fast topology-driven community detection, optional weights and seeds.
- Node Similarity — Structural neighborhood similarity with Jaccard, Overlap, or Cosine.
- K-Nearest Neighbors — Property-based approximate KNN and supported metrics.
- Path finding algorithms — Current shortest path, traversal, spanning, and flow families.
- Dijkstra Source-Target — Positive-cost shortest path semantics; sourceNode/targetNodes current syntax.
- Breadth First Search — Reachability traversal, targets, maxDepth, and stream/mutate modes.
- Graph algorithm operations reference — Current procedure/function names including spanningTree and similarity functions.
- Neo4j current versions — Current Neo4j database release and 5.26 LTS line.