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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Wikipedia Link Graph and Layout Dataset (2026)
|
| 3 |
+
emoji: 🌌
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: static
|
| 7 |
+
pretty_name: Wikipedia Link Graph & Layout Dataset
|
| 8 |
+
dataset_info:
|
| 9 |
+
features:
|
| 10 |
+
- name: title
|
| 11 |
+
dtype: string
|
| 12 |
+
- name: idx
|
| 13 |
+
dtype: int64
|
| 14 |
+
- name: category
|
| 15 |
+
dtype: int64
|
| 16 |
+
- name: views
|
| 17 |
+
dtype: int64
|
| 18 |
+
- name: x
|
| 19 |
+
dtype: float64
|
| 20 |
+
- name: y
|
| 21 |
+
dtype: float64
|
| 22 |
+
splits:
|
| 23 |
+
- name: train
|
| 24 |
+
num_examples: 5483256
|
| 25 |
+
tags:
|
| 26 |
+
- graph
|
| 27 |
+
- wikipedia
|
| 28 |
+
- webgl
|
| 29 |
+
- sqlite
|
| 30 |
+
- rapids
|
| 31 |
+
- network
|
| 32 |
+
- link-prediction
|
| 33 |
+
- community-detection
|
| 34 |
+
- representation-learning
|
| 35 |
+
size_categories:
|
| 36 |
+
- 10M-100M
|
| 37 |
+
---
|
| 38 |
+
|
| 39 |
+
# Wikipedia Link Graph, layout, and Contexts Dataset
|
| 40 |
+
|
| 41 |
+
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.
|
| 42 |
+
|
| 43 |
+
This data directly backs the **Wikipedia Graph Visualizer**, an interactive cosmic WebGL space showing Wikipedia as a stellar galaxy.
|
| 44 |
+
|
| 45 |
+
* **GitHub Repository:** [ICYBAWSS/wikipedia_graph](https://github.com/ICYBAWSS/wikipedia_graph)
|
| 46 |
+
* **Interactive Visualizer:** [Live Demo](https://icybawss.github.io/wikipedia_graph/)
|
| 47 |
+
|
| 48 |
+
---
|
| 49 |
+
|
| 50 |
+
## 📁 File Structure & Specifications
|
| 51 |
+
|
| 52 |
+
The dataset includes raw dumps, processed structured databases, optimized binary indices, and graph edge lists.
|
| 53 |
+
|
| 54 |
+
| File Path in Repo | Size | Format | Description |
|
| 55 |
+
| :--- | :--- | :--- | :--- |
|
| 56 |
+
| `wiki_graph_structure.db` | **3.12 GB** | SQLite | Clean relational database of `nodes` and `links` tables. Ideal for general-purpose SQL queries. |
|
| 57 |
+
| `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. |
|
| 58 |
+
| `test_scrape/wiki_graph.db` | **25.30 GB** | SQLite | Duplicate of `wiki_simulation.db` (retained for pipeline naming consistency). |
|
| 59 |
+
| `test_scrape/wiki_cache.db` | **21.77 GB** | SQLite | Crawled and processed raw wikitext articles from the pipeline scraper. |
|
| 60 |
+
| `test_scrape/enwiki-latest-pages-articles-multistream.xml.bz2` | **24.32 GB** | BZ2 | Raw XML Wikipedia multistream dump from Wikimedia. |
|
| 61 |
+
| `test_scrape/pageviews.bz2` | **5.86 GB** | BZ2 | Raw monthly user pageview counts dump from Wikimedia. |
|
| 62 |
+
| `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. |
|
| 63 |
+
| `metadata.csv` | **138.97 MB** | CSV | Tabular index of node indices, titles, parent category IDs, and views metrics. |
|
| 64 |
+
| `adjacency_csr.bin.gz` | **248.76 MB** | Binary (GZIP) | Packed Compressed Sparse Row (CSR) representation of out-edges for fast traversal. |
|
| 65 |
+
| `adjacency_csr_rev.bin.gz` | **252.27 MB** | Binary (GZIP) | Packed Compressed Sparse Row (CSR) representation of in-edges (incoming links). |
|
| 66 |
+
| `viewer_v2.bin.gz` | **35.18 MB** | Binary (GZIP) | Packed client-side array containing node indices, quantized coordinates, and node sizes. |
|
| 67 |
+
| `titles_v2.bin.gz` | **47.63 MB** | Binary (GZIP) | Sequentially concatenated UTF-8 title byte index for zero-cost offset lookups. |
|
| 68 |
+
|
| 69 |
+
---
|
| 70 |
+
|
| 71 |
+
## 🏛️ Schema Definitions (SQLite)
|
| 72 |
+
|
| 73 |
+
### 1. `wiki_graph_structure.db` (Clean Schema)
|
| 74 |
+
|
| 75 |
+
This SQLite database contains the core relational schemas:
|
| 76 |
+
|
| 77 |
+
* **`nodes` Table:**
|
| 78 |
+
```sql
|
| 79 |
+
CREATE TABLE nodes (
|
| 80 |
+
idx INTEGER PRIMARY KEY, -- 0-indexed node sequence ID
|
| 81 |
+
title TEXT UNIQUE, -- Wikipedia Article Name (UTF-8)
|
| 82 |
+
category INTEGER, -- Wikipedia Category ID mapping
|
| 83 |
+
views INTEGER, -- Monthly Pageviews count
|
| 84 |
+
x INTEGER, -- Force-directed X coordinate (quantized uint16)
|
| 85 |
+
y INTEGER -- Force-directed Y coordinate (quantized uint16)
|
| 86 |
+
);
|
| 87 |
+
CREATE INDEX idx_nodes_title ON nodes(title);
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
* **`links` Table:**
|
| 91 |
+
```sql
|
| 92 |
+
CREATE TABLE links (
|
| 93 |
+
source_idx INTEGER, -- Source node idx
|
| 94 |
+
target_idx INTEGER, -- Target node idx
|
| 95 |
+
FOREIGN KEY(source_idx) REFERENCES nodes(idx),
|
| 96 |
+
FOREIGN KEY(target_idx) REFERENCES nodes(idx)
|
| 97 |
+
);
|
| 98 |
+
CREATE INDEX idx_links_source ON links(source_idx);
|
| 99 |
+
CREATE INDEX idx_links_target ON links(target_idx);
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
### 2. `test_scrape/wiki_simulation.db` (Visualizer Backend Schema)
|
| 103 |
+
|
| 104 |
+
This production database expands on the clean schema with full-text search indexes and link wikitext context snippets:
|
| 105 |
+
|
| 106 |
+
* **`contexts` Table:**
|
| 107 |
+
```sql
|
| 108 |
+
CREATE TABLE contexts (
|
| 109 |
+
source_idx INTEGER, -- Source node idx
|
| 110 |
+
target_idx INTEGER, -- Target node idx
|
| 111 |
+
context TEXT, -- exact raw wikitext sentence containing the hyperlink
|
| 112 |
+
PRIMARY KEY (source_idx, target_idx)
|
| 113 |
+
);
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
---
|
| 117 |
+
|
| 118 |
+
## ⚡ Loading & Access Examples
|
| 119 |
+
|
| 120 |
+
### 1. SQLite Query Examples
|
| 121 |
+
To find the shortest paths or navigate link hierarchies, query the SQLite database locally or stream it:
|
| 122 |
+
|
| 123 |
+
```sql
|
| 124 |
+
-- Get the out-links (pages mentioned in the article 'SpaceX')
|
| 125 |
+
SELECT n.title
|
| 126 |
+
FROM links l
|
| 127 |
+
JOIN nodes n ON l.target_idx = n.idx
|
| 128 |
+
WHERE l.source_idx = (SELECT idx FROM nodes WHERE title = 'SpaceX');
|
| 129 |
+
|
| 130 |
+
-- Get the in-links (pages linking back to 'Artificial intelligence')
|
| 131 |
+
SELECT n.title
|
| 132 |
+
FROM links l
|
| 133 |
+
JOIN nodes n ON l.source_idx = n.idx
|
| 134 |
+
WHERE l.target_idx = (SELECT idx FROM nodes WHERE title = 'Artificial intelligence');
|
| 135 |
+
|
| 136 |
+
-- Find context wikitext snippet explaining a connection
|
| 137 |
+
SELECT context
|
| 138 |
+
FROM contexts
|
| 139 |
+
WHERE source_idx = (SELECT idx FROM nodes WHERE title = 'Python (programming language)')
|
| 140 |
+
AND target_idx = (SELECT idx FROM nodes WHERE title = 'C++');
|
| 141 |
+
```
|
| 142 |
+
|
| 143 |
+
### 2. Streaming via HTTP Range Requests (SQLite VFS)
|
| 144 |
+
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.
|
| 145 |
+
|
| 146 |
+
#### Javascript/HTML integration:
|
| 147 |
+
```javascript
|
| 148 |
+
import { createDbWorker } from "sql-httpvfs";
|
| 149 |
+
|
| 150 |
+
const workerUrl = new URL("sqlite.worker.js", import.meta.url).href;
|
| 151 |
+
const wasmUrl = new URL("sql-wasm.wasm", import.meta.url).href;
|
| 152 |
+
|
| 153 |
+
const dbUrl = "https://huggingface.co/datasets/icybawss/wikipedia-graph-data/resolve/main/test_scrape/wiki_simulation.db";
|
| 154 |
+
|
| 155 |
+
const worker = await createDbWorker(
|
| 156 |
+
[
|
| 157 |
+
{
|
| 158 |
+
from: "inline",
|
| 159 |
+
config: {
|
| 160 |
+
serverMode: "full",
|
| 161 |
+
requestChunkSize: 65536, // 64KB range queries
|
| 162 |
+
url: dbUrl
|
| 163 |
+
}
|
| 164 |
+
}
|
| 165 |
+
],
|
| 166 |
+
workerUrl,
|
| 167 |
+
wasmUrl
|
| 168 |
+
);
|
| 169 |
+
|
| 170 |
+
// Query is translated directly to HTTP 206 Partial Content range requests
|
| 171 |
+
const results = await worker.db.query(
|
| 172 |
+
"SELECT context FROM contexts WHERE source_idx = 1010 AND target_idx = 2020"
|
| 173 |
+
);
|
| 174 |
+
console.log(results[0].context);
|
| 175 |
+
```
|
| 176 |
+
|
| 177 |
+
### 3. Reading CSR Traversal Binaries (Python)
|
| 178 |
+
The Compressed Sparse Row binaries contain contiguous arrays of indices for instantaneous link graph traversals without SQL execution overhead.
|
| 179 |
+
|
| 180 |
+
```python
|
| 181 |
+
import numpy as np
|
| 182 |
+
import gzip
|
| 183 |
+
|
| 184 |
+
# Read packed CSR binary
|
| 185 |
+
with gzip.open("adjacency_csr.bin.gz", "rb") as f:
|
| 186 |
+
# 32-bit integer header: [N, E]
|
| 187 |
+
header = np.frombuffer(f.read(8), dtype=np.uint32)
|
| 188 |
+
N, E = header[0], header[1]
|
| 189 |
+
|
| 190 |
+
# Offsets array (size N + 1): points to starting bounds of target connections
|
| 191 |
+
offsets = np.frombuffer(f.read((N + 1) * 4), dtype=np.uint32)
|
| 192 |
+
|
| 193 |
+
# Columns array (size E): stores the actual target indices
|
| 194 |
+
columns = np.frombuffer(f.read(E * 4), dtype=np.uint32)
|
| 195 |
+
|
| 196 |
+
def get_neighbors(node_idx):
|
| 197 |
+
if node_idx < 0 or node_idx >= N:
|
| 198 |
+
return []
|
| 199 |
+
start = offsets[node_idx]
|
| 200 |
+
end = offsets[node_idx + 1]
|
| 201 |
+
return columns[start:end]
|
| 202 |
+
|
| 203 |
+
print("Out-links for node ID 1010:", get_neighbors(1010))
|
| 204 |
+
```
|
| 205 |
+
|
| 206 |
+
---
|
| 207 |
+
|
| 208 |
+
## ⚙️ Layout & Data Pipeline
|
| 209 |
+
|
| 210 |
+
The dataset coordinates and binaries were generated via a multi-stage distributed pipeline:
|
| 211 |
+
|
| 212 |
+
1. **Wikipedia Extraction:** Standard SAX parsing of `enwiki-latest-pages-articles-multistream.xml.bz2` extracting valid hyperlinks.
|
| 213 |
+
2. **Pageviews Merging:** Joining nodes with monthly counts inside `pageviews.bz2` to compute node weight and relative radius sizing.
|
| 214 |
+
3. **Layout Generation:** Running a **GPU-accelerated ForceAtlas2 force-directed physics layout** using **NVIDIA RAPIDS cuGraph** over the complete 100M+ link edge-list.
|
| 215 |
+
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.
|
| 216 |
+
5. **CSR Indexing:** Compiling out-links and in-links arrays to pack structural graph traversal bytes.
|
| 217 |
+
|
| 218 |
+
---
|
| 219 |
+
|
| 220 |
+
## ⚖️ Citation & License
|
| 221 |
+
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**.
|