File size: 8,957 Bytes
84f1f96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
---
title: Wikipedia Link Graph and Layout Dataset (2026)
emoji: 🌌
colorFrom: indigo
colorTo: purple
sdk: static
pretty_name: Wikipedia Link Graph & Layout Dataset
dataset_info:
  features:
  - name: title
    dtype: string
  - name: idx
    dtype: int64
  - name: category
    dtype: int64
  - name: views
    dtype: int64
  - name: x
    dtype: float64
  - name: y
    dtype: float64
  splits:
  - name: train
    num_examples: 5483256
tags:
- graph
- wikipedia
- webgl
- sqlite
- rapids
- network
- link-prediction
- community-detection
- representation-learning
size_categories:
- 10M-100M
---

# Wikipedia Link Graph, layout, and Contexts Dataset

This repository hosts the complete, high-fidelity graph dataset of the **English Wikipedia** (approx. **5.48M articles/nodes** and **100M+ links/edges**). It is designed to enable researchers, developers, and graph-database enthusiasts to study massive web graphs, run node classification, representation learning (Node2Vec, GNNs), and explore spatial force-directed graph layouts.

This data directly backs the **Wikipedia Graph Visualizer**, an interactive cosmic WebGL space showing Wikipedia as a stellar galaxy.

* **GitHub Repository:** [ICYBAWSS/wikipedia_graph](https://github.com/ICYBAWSS/wikipedia_graph)
* **Interactive Visualizer:** [Live Demo](https://icybawss.github.io/wikipedia_graph/)

---

## 📁 File Structure & Specifications

The dataset includes raw dumps, processed structured databases, optimized binary indices, and graph edge lists.

| File Path in Repo | Size | Format | Description |
| :--- | :--- | :--- | :--- |
| `wiki_graph_structure.db` | **3.12 GB** | SQLite | Clean relational database of `nodes` and `links` tables. Ideal for general-purpose SQL queries. |
| `test_scrape/wiki_simulation.db` | **25.30 GB** | SQLite | **Production Database**. Contains the node graph, full-text search indexes (`fts_idx`), and wikitext snippets surrounding links (`contexts` table) used by the visualizer. |
| `test_scrape/wiki_graph.db` | **25.30 GB** | SQLite | Duplicate of `wiki_simulation.db` (retained for pipeline naming consistency). |
| `test_scrape/wiki_cache.db` | **21.77 GB** | SQLite | Crawled and processed raw wikitext articles from the pipeline scraper. |
| `test_scrape/enwiki-latest-pages-articles-multistream.xml.bz2` | **24.32 GB** | BZ2 | Raw XML Wikipedia multistream dump from Wikimedia. |
| `test_scrape/pageviews.bz2` | **5.86 GB** | BZ2 | Raw monthly user pageview counts dump from Wikimedia. |
| `edges_weighted.csv.gz` | **1.25 GB** | CSV (GZIP) | Tabular list of source and target node indices with weights. Useful for deep learning/GNN imports. |
| `metadata.csv` | **138.97 MB** | CSV | Tabular index of node indices, titles, parent category IDs, and views metrics. |
| `adjacency_csr.bin.gz` | **248.76 MB** | Binary (GZIP) | Packed Compressed Sparse Row (CSR) representation of out-edges for fast traversal. |
| `adjacency_csr_rev.bin.gz` | **252.27 MB** | Binary (GZIP) | Packed Compressed Sparse Row (CSR) representation of in-edges (incoming links). |
| `viewer_v2.bin.gz` | **35.18 MB** | Binary (GZIP) | Packed client-side array containing node indices, quantized coordinates, and node sizes. |
| `titles_v2.bin.gz` | **47.63 MB** | Binary (GZIP) | Sequentially concatenated UTF-8 title byte index for zero-cost offset lookups. |

---

## 🏛️ Schema Definitions (SQLite)

### 1. `wiki_graph_structure.db` (Clean Schema)

This SQLite database contains the core relational schemas:

* **`nodes` Table:**
  ```sql
  CREATE TABLE nodes (
      idx INTEGER PRIMARY KEY,   -- 0-indexed node sequence ID
      title TEXT UNIQUE,         -- Wikipedia Article Name (UTF-8)
      category INTEGER,          -- Wikipedia Category ID mapping
      views INTEGER,             -- Monthly Pageviews count
      x INTEGER,                 -- Force-directed X coordinate (quantized uint16)
      y INTEGER                  -- Force-directed Y coordinate (quantized uint16)
  );
  CREATE INDEX idx_nodes_title ON nodes(title);
  ```

* **`links` Table:**
  ```sql
  CREATE TABLE links (
      source_idx INTEGER,        -- Source node idx
      target_idx INTEGER,        -- Target node idx
      FOREIGN KEY(source_idx) REFERENCES nodes(idx),
      FOREIGN KEY(target_idx) REFERENCES nodes(idx)
  );
  CREATE INDEX idx_links_source ON links(source_idx);
  CREATE INDEX idx_links_target ON links(target_idx);
  ```

### 2. `test_scrape/wiki_simulation.db` (Visualizer Backend Schema)

This production database expands on the clean schema with full-text search indexes and link wikitext context snippets:

* **`contexts` Table:**
  ```sql
  CREATE TABLE contexts (
      source_idx INTEGER,        -- Source node idx
      target_idx INTEGER,        -- Target node idx
      context TEXT,              -- exact raw wikitext sentence containing the hyperlink
      PRIMARY KEY (source_idx, target_idx)
  );
  ```

---

## ⚡ Loading & Access Examples

### 1. SQLite Query Examples
To find the shortest paths or navigate link hierarchies, query the SQLite database locally or stream it:

```sql
-- Get the out-links (pages mentioned in the article 'SpaceX')
SELECT n.title 
FROM links l 
JOIN nodes n ON l.target_idx = n.idx 
WHERE l.source_idx = (SELECT idx FROM nodes WHERE title = 'SpaceX');

-- Get the in-links (pages linking back to 'Artificial intelligence')
SELECT n.title 
FROM links l 
JOIN nodes n ON l.source_idx = n.idx 
WHERE l.target_idx = (SELECT idx FROM nodes WHERE title = 'Artificial intelligence');

-- Find context wikitext snippet explaining a connection
SELECT context 
FROM contexts 
WHERE source_idx = (SELECT idx FROM nodes WHERE title = 'Python (programming language)')
  AND target_idx = (SELECT idx FROM nodes WHERE title = 'C++');
```

### 2. Streaming via HTTP Range Requests (SQLite VFS)
Because downloading the full `25.30 GB` database is impractical in the browser, the visualizer uses `sql-httpvfs` to stream chunks of the database directly from Hugging Face on-demand.

#### Javascript/HTML integration:
```javascript
import { createDbWorker } from "sql-httpvfs";

const workerUrl = new URL("sqlite.worker.js", import.meta.url).href;
const wasmUrl = new URL("sql-wasm.wasm", import.meta.url).href;

const dbUrl = "https://huggingface.co/datasets/icybawss/wikipedia-graph-data/resolve/main/test_scrape/wiki_simulation.db";

const worker = await createDbWorker(
  [
    {
      from: "inline",
      config: {
        serverMode: "full",
        requestChunkSize: 65536, // 64KB range queries
        url: dbUrl
      }
    }
  ],
  workerUrl,
  wasmUrl
);

// Query is translated directly to HTTP 206 Partial Content range requests
const results = await worker.db.query(
  "SELECT context FROM contexts WHERE source_idx = 1010 AND target_idx = 2020"
);
console.log(results[0].context);
```

### 3. Reading CSR Traversal Binaries (Python)
The Compressed Sparse Row binaries contain contiguous arrays of indices for instantaneous link graph traversals without SQL execution overhead.

```python
import numpy as np
import gzip

# Read packed CSR binary
with gzip.open("adjacency_csr.bin.gz", "rb") as f:
    # 32-bit integer header: [N, E]
    header = np.frombuffer(f.read(8), dtype=np.uint32)
    N, E = header[0], header[1]
    
    # Offsets array (size N + 1): points to starting bounds of target connections
    offsets = np.frombuffer(f.read((N + 1) * 4), dtype=np.uint32)
    
    # Columns array (size E): stores the actual target indices
    columns = np.frombuffer(f.read(E * 4), dtype=np.uint32)

def get_neighbors(node_idx):
    if node_idx < 0 or node_idx >= N:
        return []
    start = offsets[node_idx]
    end = offsets[node_idx + 1]
    return columns[start:end]

print("Out-links for node ID 1010:", get_neighbors(1010))
```

---

## ⚙️ Layout & Data Pipeline

The dataset coordinates and binaries were generated via a multi-stage distributed pipeline:

1. **Wikipedia Extraction:** Standard SAX parsing of `enwiki-latest-pages-articles-multistream.xml.bz2` extracting valid hyperlinks.
2. **Pageviews Merging:** Joining nodes with monthly counts inside `pageviews.bz2` to compute node weight and relative radius sizing.
3. **Layout Generation:** Running a **GPU-accelerated ForceAtlas2 force-directed physics layout** using **NVIDIA RAPIDS cuGraph** over the complete 100M+ link edge-list. 
4. **Quantization:** Squeezing the double-precision float $(x, y)$ layout outputs into 16-bit unsigned integers mapped to a $384 \times 384$ coordinate grid system.
5. **CSR Indexing:** Compiling out-links and in-links arrays to pack structural graph traversal bytes.

---

## ⚖️ Citation & License
This dataset is compiled from the Wikimedia XML database dumps and pageviews files, which are distributed under the **Creative Commons Attribution-ShareAlike 4.0 International License (CC BY-SA 4.0)**. All code and scripts in the accompanying GitHub repository are licensed under the **MIT License**.