Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

From Wikipedia to a graph

This page explains, in plain words, how build turns Wikipedia tables into nodes and edges. The exact rules are in the “Builder responsibilities” part of the WGRF specification.

Nodes are articles

A node is a page of the main namespace (page_namespace = 0) that is not a redirect. Talk pages, user pages, categories and templates are not in the graph.

Nodes are numbered from 0, in the order of their Wikipedia page_id. The graph keeps the page_id of each node in the page_id column, so you can go back to Wikipedia.

Titles are stored as Wikipedia shows them, with spaces: Tour_Eiffel becomes Tour Eiffel.

Redirects are names, not nodes

A redirect such as Paris (France) is not a node. The builder follows it to the real article and:

  • adds its title as an extra searchable name (an alias) for that article,
  • rewrites every link to the redirect so that it points to the article.

The builder follows chains of redirects up to 8 steps. It drops a redirect that loops, is longer, points to a missing page, to another namespace or to another wiki. Links to a dropped redirect are dropped too.

The pagelinks table says “page A links to link target T”. The linktarget table gives the title of T. The builder resolves that title to a node, through redirects if needed.

A link becomes an edge only when both ends are articles in the graph. Then, for each article:

  • targets are sorted by node id,
  • duplicates are removed (two links can reach one article through different redirects),
  • a link from an article to itself is removed.

Red links (links to pages that don’t exist) are dropped.

Categories come from Wikidata

Some pages are hubs that connect almost everything: dates (14 juillet, 1913, XIXe siècle) and countries (France). They make paths short but not interesting. To let you skip them, each node has one category byte.

The category comes from the Wikidata item of the article:

  1. download asks the Wikidata Query Service for all items that are an “instance of” a day, a date, a month, a year, a decade, a century, a millennium, a “year in topic” page or a country, and that have an article on French Wikipedia.
  2. build reads the page_props table to find the Wikidata item of each article, and looks it up in that list.

The spec has the full list of values and the Wikidata classes behind each one.

path and explore use this column with --exclude-date-page and --exclude-country.

Clicks come from the clickstream

Wikimedia publishes a monthly clickstream: how many times readers went from one page to another. When build finds a clickstream file, it gives each edge the number of clicks measured on it, in the click_count column.

  • Only rows of type link count. Rows from search engines, other sites or the search box don’t.
  • Both titles resolve like links do, through redirects. Clicks that land on the same edge through different redirects add up.
  • A row whose link is not in the graph is dropped. The clickstream month and the dump date differ, so a link can have been added or removed in between.
  • The clickstream leaves out pairs with fewer than 10 clicks in the month. Most edges have no count at all: that means “not measured”, not “never clicked”.

Each node also gets a view_count: the sum of every clickstream row that ends on the page, whatever the referer (another article, a search engine, another site, none). It is close to the page’s views for the month, a little lower because of the missing small pairs.

path and explore use both columns, see Path search. They count a missing value as 0.

What the graph looks like

Output of info on the 2026-09-01 dump:

Degrees            mean   median      p99          max        zero
  out-links        84.7       40      612        5,374         254 dead ends
  in-links         84.7       14      862      570,854      46,002 orphans
  reciprocal edges: 112,781,200 (48.0 %), linked both ways
  • A typical article links to about 40 others.
  • A few pages get a huge number of links: France has more than 550,000 incoming links.
  • 46,002 articles have no incoming link: you can’t reach them by clicking.
  • 254 articles have no outgoing link: a path can end there, but not go through them.