citation-topics · Sample board · GitHub

How the topics are made: the Leiden algorithm

citation-topics finds the topics of any list of works from their citations alone, with no list of fields decided in advance. This page explains, as simply as possible, how a computer finds them and how each work gets its topic. The numbers come from the largest list it has been run on: the 1.87 million papers of INSPIRE-HEP, grouped into 304 topics (inspireauth10, which the package reproduces exactly); the last sections say what the package does with a list of any size and how to see the result.

1. Papers that cite each other form a topic

Draw every paper as a dot and every citation as a line between two dots (it does not matter who cites whom). The whole of INSPIRE gives 1.87 million dots and 44.3 million lines. Papers on the same subject cite each other much more than they cite papers on other subjects, so the drawing has dense groups with only a few lines between them. A topic is one of those dense groups.

Topic ATopic B few links between
Twelve papers. Ten citations inside each group, only two (dashed) between them: the natural split is the two coloured groups.

With twelve dots the groups can be seen by eye. With 1.87 million they cannot, so the computer needs a score that says how good a split into groups is, and a fast way to find a split with a high score. The Leiden algorithm (Traag, Waltman & van Eck 2019) does both.

2. The score: more links inside than chance would give

Counting the links inside the groups is not enough: putting every paper in one single group would keep every link inside. The score therefore compares the links inside each group with the number of links the group would have by chance, if the same papers, each with the same number of citations, were wired at random. A good topic has many more links inside than chance gives. This score is the modularity of Newman (2006).

Chance gives more links between papers that have many links. A paper with k links meets a group whose papers have K links in all about k × K / (2m) times at random, where m is the number of links in the whole network. So, for one paper, the gain of joining a topic is:

gain = (its links to the topic) − γ × k × K / (2m)

The number γ is the resolution (Reichardt & Bornholdt 2006). It decides how large the topics are: with a large γ the "chance" term weighs more, big groups stop paying off, and the network splits into more, smaller topics. On INSPIRE-HEP the default γ = 16 gives 304 topics of typically a few thousand papers; γ = 4 gives only 69 topics, and γ = 32, 623. A list of a few thousand works needs a much smaller γ: the sample board uses γ = 1 for 1,967 works and gets 11 topics.

small γ: one topic larger γ: two topics very large γ: four topics
The resolution γ works like the zoom of a microscope: the same papers form broad fields at low γ and narrow subjects at high γ.

3. How Leiden searches

Trying every possible split is impossible, so Leiden improves a split step by step:

  1. Move. Start with every paper alone. Visit the papers one by one and move each to the neighbouring group where its gain is largest (or leave it where it is). Repeat until no move helps.
  2. Refine. Check that every group is really held together by its own links; a group that is two separate pieces is split. This step is what Leiden adds to the older Louvain algorithm, which could leave such broken groups (Traag, Waltman & van Eck 2019).
  3. Merge. Replace each group by one big dot (its inside links become a loop on the dot, its outside links become thick lines) and go back to step 1 with these dots, so that whole groups can move together.
1. move papers 2. refine: split broken groups no link 3. merge groups into dots loop = links inside
Left: the grey paper is moved to the blue group, where it has more links than chance gives. Middle: a group whose two halves have no link between them is split. Right: each group becomes one dot and the search continues one level up.

The three steps are repeated until the score stops rising. In the end every paper has exactly one topic: the group where, given all the other papers, it adds most to the score. That is its main topic.

4. An example: why Geant4 is not in the LHC topic

The Geant4 simulation toolkit paper (2003) is the most cited paper of the network, with 20,392 citation links. 3,919 of them go to papers of the topic LHC experiments and the Higgs discovery, but only 1,348 to the topic Geant4 and detector simulation. Still, Leiden puts it in the second one. The gain explains why:

TopicGeant4's links thereAll links of the topic's papersExpected by chance (γ = 16)Gain
Geant4 and detector simulation1,348117,958434+914
LHC experiments and the Higgs discovery3,9191,097,7654,038−119
Silicon trackers and LHC detector upgrades360179,020659−299
Geant4 and detector simulation 1,348 links 434 expected LHC experiments and Higgs 3,919 links 4,038 expected Silicon trackers, LHC upgrades 360 links 659 expected
Geant4's links to the topiclinks expected by chance (γ = 16)
Only in its own topic does Geant4 have far more links than chance gives (three times more). With the LHC topic it has about the number chance predicts.

citation-topics also gives each work a second and third topic: the other topics with most links, scored as their links divided by the links to the main topic (at most 1). That score counts raw links, with no correction for chance, so a widely used tool such as Geant4 gets a second topic with score 1 (the LHC topic), while Leiden's gain for it is about zero.

5. What citation-topics does exactly

6. Seeing the topics: the network of works

When the list has at most 10,000 works (--network-max), the board has a Network tab that draws every work with a citation link as a dot and every citation link as a line, with each topic as its own cluster, labelled with its name. The positions are made in two steps, so that each cluster really is one topic:

  1. Each topic becomes a disc whose area is proportional to its works. The discs are placed by the links between topics (topics that cite each other more sit closer; Fruchterman–Reingold layout of the graph of topics) and then pushed apart until none overlap.
  2. Inside each disc, the topic's works are placed by the links among them (Fruchterman–Reingold again), so that works that cite each other sit together.

Dots are coloured by area and sized by citations. Clicking a work leaves only its own citation links, in one colour to the works it cites and in another to the works citing it, and the works at their other end, with its first author beside it and its title, authors, year, citations, topic and link in a box below the graph. The same positions go into works_vosviewer.json (citation-topics export OUT --works INPUT), a VOSviewer file with one item per work, its topic as the cluster (named), its citations and year, and its link. VOSviewer Online opens such a file from a public address: https://app.vosviewer.com/?json= followed by the file's URL. The sample board's file opens with this link. In VOSviewer the clusters can be recomputed and the works re-laid with its own method (VOS mapping and clustering); the file keeps the topics of citation-topics until that is done.

References