liveBook · Manning

Label propagation

As explained in Graph Algorithms for Data Science

A label propagation algorithm is a community detection algorithm that iteratively propagates node labels through graph connections to identify groups of related nodes.

Label propagation (LPA) finds nonoverlapping communities: groups of densely interconnected nodes with sparser links to other groups. Unlike a weakly connected component, which only requires nodes to be reachable when relationship direction is ignored, a community can reveal distinct clusters inside one connected network. section 7.4 section 7.7

It is useful after turning a bipartite dataset into a co-occurrence network. For example, tweets and hashtags can be projected into a hashtag network, then grouped to identify related hashtag themes for analysis. section 7.0 section 7.7

A practical Neo4j Graph Data Science workflow is:

  • Run `gds.labelPropagation.mutate` on the in-memory graph, selecting `Tag` nodes and `CO_OCCURRENCE` relationships and saving a `community` property. section 7.4
  • Write the mutated `community` property from the in-memory graph to the stored graph with `gds.graph.writeNodeProperties`. section 7.4
  • Group tags by community, count their members, and inspect representative tags to interpret the largest clusters. section 7.4
  • Treat repeated runs carefully: LPA is nondeterministic because node-label update order is randomly decided, so results can vary on the same data. section 7.4

Interpreting hashtag communities

A large detected community includes `#programming`, `#ml`, `#iotpl`, `#rstats`, `#cybersecurity`, and `#serverless`. Another community containing `#nlp` includes `#datascience`, `#ai`, `#machinelearning`, `#python`, and `#deeplearning`. Such member lists turn numeric community IDs into analyzable themes. section 7.4

Listing 7.16 Executing the label propagation algorithm on the hashtag co-occurrence network and storing the results to the in-memory graph
CALL gds.labelPropagation.mutate('tags',
 {nodeLabels:['Tag'], relationshipTypes: ['CO_OCCURRENCE'],
  mutateProperty:'community'})
YIELD communityCount, communityDistribution;

Use the runnable mutate query as a starting point for assigning community IDs to nodes in a projected hashtag co-occurrence graph. section 7.4

How Graph Algorithms for Data Science covers it

How deep it goes
Explains communities versus weakly connected components and gives mutation, persistence, and inspection steps, without detailing label-update mechanics.
Examples
Uses tweet hashtags and reports communities containing programming, machine learning, NLP, graph, art, and gaming tags.
What it assumes
Assumes familiarity with weakly and strongly connected components while defining how communities differ from components.
What you can do after
Apply it via Neo4j Graph Data Science to assign, store, and inspect nonoverlapping community IDs.
How it connects
Connects community detection with bipartite networks, co-occurrence networks, weakly connected components, strongly connected components, and PageRank.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Algorithms for Data Science. The section links point to the parts of the book it draws on.