Lesson

What is centrality?

Full definition for centrality (opens in a new tab)How important a node is within a graph. Each centrality algorithm defines importance differently. algorithms are often described as finding the "most important" or "most influential" Full definition for node (opens in a new tab)A vertex in a graph. In a property graph it can carry labels and properties..

While that description is technically valid, they each define importance in different ways — sometimes extremely different.

In this lesson, you'll:

  • Count the Full definition for relationship (opens in a new tab)A named, directed connection between two nodes. Every relationship has a type, a start node and an end node. on a small graph and rank its nodes by hand
  • Meet the six families of similar centrality algorithms
  • Work out which node each family might identify on that same graph

By the end of this lesson, you will understand what centrality means, and how each algorithm family defines it differently.

A sample graph

Every centrality algorithm provides each node with a score, ranking nodes by importance. Each algorithm's definition of "importance" varies.

In this lesson, you will consider how these behaviors interact with the following example graph; it holds eight nodes and nine relationships.

The six families

For mnemonic purposes, we can arrange centrality algorithms into six loose families.

FamilyPerspectiveAlgorithmsThe question it answers
Tiesat the nodeDegreeHow many relationships does this node have?
Articulationwithout the nodeArticulation Points, BridgesWhich nodes or relationships, if removed, would break the graph into more components?
Reachfrom the nodeCloseness, HarmonicHow far is this node from every other node?
Gatekeepingthrough the nodeBetweennessHow many of the shortest paths between other nodes run through this one?
Endorsementinto the nodePage Rank, Article Rank, Eigenvector, HITSHow important are the nodes that point at this node?
Teamswith other nodesCELFWhich group of nodes together reaches the most of the graph?

The six initials spell TARGET.

Although there are behavioral variations, even within each family, family-members share a certain approach or perspective.

For some families, the Go to glossary for graph data science (opens in a new tab)Analysing data through the structure of its connections. Also the name of the Neo4j library that implements it. library contains many variations on a theme. For others, it provides only one.

Ties

Algorithms in the Ties family describe each node's local characteristics.

Count the relationships on each node in the example graph, then compare your counts with the table that follows.

Reveal the relationship counts
NodeRelationshipsConnected to
Bridget4Eve, Farida, Alice, Cesar
Alice3Bridget, Cesar, Dmitri
Dmitri3Alice, Mark, Mehmet
Cesar2Alice, Bridget
Mark2Dmitri, Mehmet
Mehmet2Dmitri, Mark
Eve1Bridget
Farida1Bridget

Bridget holds the most relationships, at four.

An algorithm in the Ties family would identify Bridget as the most "important" node.

The Graph Data Science library offers Full definition for degree centrality (opens in a new tab)A score for each node equal to its number of outgoing relationships. as the only member of this family.

Articulation

Algorithms in the Articulation family rank nodes and/or relationships by their "importance" to structure.

Go back to your example graph. Consider what would happen to the entire graph if you removed one, and only one, node. Run the experiment for all nodes.

The following table outlines what would happen.

Reveal what happens
Node removedWhat happens
BridgetEve and Farida each lose their only route
AliceDmitri, Mark and Mehmet lose every route to the rest
DmitriMark and Mehmet lose every route to the rest
Cesarnothing, Alice and Bridget are still joined
Marknothing, Dmitri and Mehmet are still joined

Alice, Bridget and Dmitri would be considered "important" by an algorithm in the Articulation family — removing them would break the graph into pieces.

The Graph Data Science Library provides Articulation Points and Bridges as members of this family.

Reach

Algorithms in the Reach family rank nodes by how far they sit from every other node.

Pick two nodes in the example graph. Count the hops along the shortest path from each one to the other seven nodes. Then, decide which one can reach more nodes, faster than the other.

The following table holds the full count for every node.

Reveal the hop counts
NodeTotal hops to the other sevenHops to the farthest node
Alice112
Bridget123
Dmitri133
Cesar143
Eve184
Farida184
Mark184
Mehmet184

Alice reaches the other seven nodes in eleven hops. Bridget, on four relationships, requires twelve hops. Dmitri, on three relationships like Alice, requires thirteen hops.

Algorithms of the Reach family could identify either Alice or Bridget as the most "important" nodes.

The Graph Data Science library provides Closeness Centrality and Harmonic Centrality as members of this family.

Gatekeeping

Algorithms in the Gatekeeping family rank nodes by how often they sit on the shortest path between two other nodes. They consider a node's position relative to every other node in the graph.

Take a look at your example graph. See if you can intuit which node would lie on the most shortest paths between all pairs.

The following table counts the pairs whose shortest path runs through each node.

Reveal the shortest path counts
NodeShortest paths through it, of 21An example pair
Alice12Mark to Cesar
Bridget11Eve to Farida
Dmitri10Mehmet to Alice
Cesar0none
Eve0none
Farida0none
Mark0none
Mehmet0none

Alice sits on the shortest path for twelve pairs, more than any other node.

Bridget holds one relationship more than Alice, but, at eleven pairs, an algorithm in the Gatekeeping family would still rank Bridget lower than Alice.

Cesar, Eve, Farida, Mark and Mehmet sit on no shortest path at all.

The Graph Data Science library offers Full definition for betweenness centrality (opens in a new tab)A score for each node equal to how often it lies on the shortest paths between other nodes. as the only member of this family.

Endorsement

Algorithms in the Endorsement family rank nodes by the importance of the nodes attached to them. A relationship from a high scorer is worth more than a relationship from a low-scoring node.

Go back to your example graph. Take each node in turn, and count the relationships held by each of its neighbours.

The following table ranks each node by the number of relationships held by its neighbors.

Reveal the neighbour counts
NodeNeighbours, and the relationships each holdsTotal
AliceBridget 4, Dmitri 3, Cesar 29
BridgetAlice 3, Cesar 2, Eve 1, Farida 17
CesarBridget 4, Alice 37
DmitriAlice 3, Mark 2, Mehmet 27
MarkDmitri 3, Mehmet 25
MehmetDmitri 3, Mark 25
EveBridget 44
FaridaBridget 44

Cesar and Bridget receive the same rank. But Cesar has only two relationships to Bridget's four.

Cesar receives more endorsement than Bridget because both of his neighbors have relationships of their own. Those neighbors, in turn, have relationships of their own.

Every node's score depends on the scores of its neighbours. Those neighbour scores are themselves still being worked out. Each algorithm in this family resolves that circularity by iterating over the graph until the scores stop moving.

The Graph Data Science library provides Page Rank, Article Rank, Eigenvector Centrality and HITS as members of this family.

Teams

Algorithms in the Teams family score a group of nodes rather than a single node.

Go back to your example graph. Try to intuit which two nodes together would reach the greatest number of nodes.

The following table holds that count for four of the best possible teams.

Reveal the team counts
Team of twoNodes each reaches aloneNodes the team reaches, of 8
Bridget and Dmitri5 and 48
Bridget and Mark5 and 38
Bridget and Alice5 and 46
Alice and Dmitri4 and 46

Bridget and Alice, together, reach nine nodes. However, three of those are overlapping — they can both reach them. Combined, they reach only six unique nodes.

Bridget and Mark, together, reach eight nodes. However, every node they reach is unique, so they retain their score of eight.

A node that reaches a great many nodes adds little to a team when somebody already chosen reaches the same nodes.

The Graph Data Science library offers CELF (Cost-Effective Lazy Forward) as the only member of this family.

Outside Neo4j

There's more to the Graph Data Science library than these algorithms alone.

The Graph Data Science library also allows you to define your own algorithms using the Pregel API.

In most cases, you will not need to define custom algorithms. The library's native set provides you with most of the functionality you will ever need for most use-cases.

That said, it is useful to retain the loose family designations outlined here, should you ever decide to branch out.

What centrality means

Each of the families you have just considered defines "centrality" or "importance" differently.

How those differences impact your analyses relies on your analytical intent.

To make each one more comprehensible, you could reframe their behaviors as questions, instead.

Three copies of one graph, with node sizes set by Degree, PageRank and Betweenness. Each names a different node as the largest.

FamilyThe question you are asking
TiesWhich node holds the most direct ties to other nodes?
ArticulationWhich node would break the graph by leaving?
ReachWhich node reaches the most other nodes?
GatekeepingWhich nodes control the flow of information?
EndorsementWhich node is attached to the most important nodes?
TeamsWhich nodes, together, reach the most of the graph?

These are generalized examples — your specific questions could differ, depending on your graph's structure.

Regardless, you can pick the family required by identifying which of these kinds of questions the algorithm could answer.