History of ogbl_wikikg2
The changes to the source code of this entry in the repository, newest first, each with the differences it made to the entry's files. They are also listed on GitLab.
[entries] Add the date when each entry was added, and remove icon_hash beff7c9
The dates are those of the commits that first added the entries' files (2020-08-11 for the entries of the initial commit); renamed entries keep the date of their first name. Changed: none
diff --git a/entries/ogbl_wikikg2/__init__.py b/entries/ogbl_wikikg2/__init__.py
index d8cd9bb..a35aee0 100644
--- a/entries/ogbl_wikikg2/__init__.py
+++ b/entries/ogbl_wikikg2/__init__.py
@@ -38,7 +38,7 @@ url = ['https://ogb.stanford.edu/docs/linkprop/#ogbl-wikikg2',
'https://snap.stanford.edu/ogb/data/']
citation = [('W. Hu, M. Fey, M. Zitnik, Y. Dong, H. Ren, B. Liu, M. Catasta, J. Leskovec, "Open Graph Benchmark: Datasets for Machine Learning on Graphs." Advances in Neural Information Processing Systems 33, 22118-22133 (2020)', 'https://doi.org/10.48550/arXiv.2005.00687'),
('D. Vrandečić, M. Krötzsch, "Wikidata: a free collaborative knowledgebase." Communications of the ACM 57(10), 78-85 (2014)', 'https://doi.org/10.1145/2629489')]
-icon_hash = None
+date_added = '2026-10-27'
upstream_license = ('CC0 1.0', 'https://creativecommons.org/publicdomain/zero/1.0/')
upstream_prefix = 'https://snap.stanford.edu/ogb/data'
z = 'linkproppred/wikikg-v2.zip:wikikg-v2'
[entries] Prefix the properties in the descriptions with (Node), (Edge) or (Graph) bc3dbbd
The lists of properties at the end of the descriptions marked edge properties with "Edge" but left node properties unmarked, or grouped them in "Nodes: `a`, ...; `b`, ..." items, so the kind of a property was often unclear. Every item now starts with (Node), (Edge) or (Graph), followed by the property names, a colon and the explanation, one item per property or group of properties; qualifications (kinds of nodes, networks) follow the names in parentheses. Properties that were only named got a short explanation, and a few items that named the wrong kind of property were corrected.
diff --git a/entries/ogbl_wikikg2/__init__.py b/entries/ogbl_wikikg2/__init__.py
index 8aba2d9..d8cd9bb 100644
--- a/entries/ogbl_wikikg2/__init__.py
+++ b/entries/ogbl_wikikg2/__init__.py
@@ -30,9 +30,9 @@ The triples come from three snapshots of Wikidata of 2015: those of May 2015 for
The network has the following properties:
-- `wikidata_id`: the Wikidata identifier of the entity, e.g. `Q92894`.
-- Edge `relation`: the Wikidata property of the relation, e.g. `P31`.
-- Edge `split`: the set of the benchmark the triple belongs to: `train` (May 2015), `valid` (August 2015) or `test` (November 2015)."""
+- (Node) `wikidata_id`: the Wikidata identifier of the entity, e.g. `Q92894`.
+- (Edge) `relation`: the Wikidata property of the relation, e.g. `P31`.
+- (Edge) `split`: the set of the benchmark the triple belongs to: `train` (May 2015), `valid` (August 2015) or `test` (November 2015)."""
tags = ['Informational', 'Relatedness', 'Unweighted', 'Multigraph', 'Metadata']
url = ['https://ogb.stanford.edu/docs/linkprop/#ogbl-wikikg2',
'https://snap.stanford.edu/ogb/data/']
[entries] Remove unneeded code from the entries 2c69f19
Unneeded "global files" statements, unused imports and variables, f-strings without placeholders, duplicate keys in foodweb_little_rock (keeping the order and the values used), and the second definition of get_lines() in twitter_higgs. Nothing changes in the networks or descriptions. Changed: none
diff --git a/entries/ogbl_wikikg2/__init__.py b/entries/ogbl_wikikg2/__init__.py
index 0e67c60..8aba2d9 100644
--- a/entries/ogbl_wikikg2/__init__.py
+++ b/entries/ogbl_wikikg2/__init__.py
@@ -58,7 +58,6 @@ def read_csv_gz(name, fname, **kwargs):
@coerce_props()
@annotate()
def parse(alts=None):
- global files
name = __name__.split(".")[-1]
for fnames, alt, fmt in files:
if alts is not None and alt not in alts:
[entries] New entry: ogbl_wikikg2 351dc3a
diff --git a/entries/ogbl_wikikg2/__init__.py b/entries/ogbl_wikikg2/__init__.py
new file mode 100644
index 0000000..0e67c60
--- /dev/null
+++ b/entries/ogbl_wikikg2/__init__.py
@@ -0,0 +1,102 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2026 Tiago de Paula Peixoto <tiago@skewed.de>
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Affero General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+
+import pandas
+
+from .. import *
+
+
+title = "Wikidata knowledge graph (ogbl-wikikg2, 2015)"
+description = """A knowledge graph extracted from Wikidata, from the `ogbl-wikikg2` dataset of the Open Graph Benchmark (OGB), a benchmark for link prediction (version 1, of December 2020). Each node is an entity of Wikidata (e.g. a person, a place, a work or a concept), and a directed edge from entity A to entity B is a statement (A, relation, B) of Wikidata with one of 535 relations (Wikidata properties, e.g. `P31`, "instance of", or `P27`, "country of citizenship"). Pairs of entities may be connected by several edges with different relations. Rare entities were filtered out by the OGB authors.
+
+The triples come from three snapshots of Wikidata of 2015: those of May 2015 form the training set of the benchmark, and those added in the snapshots of August and November 2015 form the validation and test sets (429,456 and 598,543 triples); all of them are included, and the set is given as an edge property. The negative samples of the benchmark are left out. The data do not include the labels of the entities and relations, which can be looked up in Wikidata (some entities and relations may have been removed from Wikidata since 2015).
+
+The network has the following properties:
+
+- `wikidata_id`: the Wikidata identifier of the entity, e.g. `Q92894`.
+- Edge `relation`: the Wikidata property of the relation, e.g. `P31`.
+- Edge `split`: the set of the benchmark the triple belongs to: `train` (May 2015), `valid` (August 2015) or `test` (November 2015)."""
+tags = ['Informational', 'Relatedness', 'Unweighted', 'Multigraph', 'Metadata']
+url = ['https://ogb.stanford.edu/docs/linkprop/#ogbl-wikikg2',
+ 'https://snap.stanford.edu/ogb/data/']
+citation = [('W. Hu, M. Fey, M. Zitnik, Y. Dong, H. Ren, B. Liu, M. Catasta, J. Leskovec, "Open Graph Benchmark: Datasets for Machine Learning on Graphs." Advances in Neural Information Processing Systems 33, 22118-22133 (2020)', 'https://doi.org/10.48550/arXiv.2005.00687'),
+ ('D. Vrandečić, M. Krötzsch, "Wikidata: a free collaborative knowledgebase." Communications of the ACM 57(10), 78-85 (2014)', 'https://doi.org/10.1145/2629489')]
+icon_hash = None
+upstream_license = ('CC0 1.0', 'https://creativecommons.org/publicdomain/zero/1.0/')
+upstream_prefix = 'https://snap.stanford.edu/ogb/data'
+z = 'linkproppred/wikikg-v2.zip:wikikg-v2'
+splits = ['train', 'valid', 'test']
+files = [((f'{z}/mapping/nodeidx2entityid.csv.gz',) +
+ tuple(f'{z}/original/{s}_2015.csv.gz' for s in splits), None, None)]
+
+def fetch_upstream(force=False):
+ return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+ force)
+
+def read_csv_gz(name, fname, **kwargs):
+ with open_upstream_file(name, fname, "rb") as f:
+ return pandas.read_csv(f, compression="gzip", **kwargs)
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+ global files
+ name = __name__.split(".")[-1]
+ for fnames, alt, fmt in files:
+ if alts is not None and alt not in alts:
+ continue
+ # "node idx,entity id"
+ nodes = read_csv_gz(name, fnames[0])
+ assert (nodes["node idx"].values == numpy.arange(len(nodes))).all()
+ entities = pandas.Index(nodes["entity id"].values)
+ del nodes
+ assert entities.is_unique
+
+ g = Graph(directed=True)
+ g.add_vertex(len(entities))
+ rels = []
+ esplits = []
+ extra = []
+ for fname, split in zip(fnames[1:], splits):
+ # "<head>,<relation>,<tail>"
+ t = read_csv_gz(name, fname, header=None, dtype="category")
+ ends = []
+ for c in [0, 2]:
+ idx = entities.get_indexer(t[c].cat.categories)
+ missing = idx < 0
+ if missing.any():
+ # entities absent from the mapping (none are expected)
+ new = t[c].cat.categories[missing]
+ extra.extend(new)
+ entities = entities.append(pandas.Index(new))
+ idx = entities.get_indexer(t[c].cat.categories)
+ ends.append(idx[t[c].cat.codes.values])
+ g.add_edge_list(numpy.column_stack(ends))
+ cats = list(t[1].cat.categories)
+ rels.extend(cats[i] for i in t[1].cat.codes.values)
+ esplits.extend([split] * len(t))
+ del t, ends
+ assert len(extra) == 0, extra[:10]
+ g.vp.wikidata_id = g.new_vp("string", vals=entities)
+ g.ep.relation = g.new_ep("string", vals=rels)
+ del rels
+ g.ep.split = g.new_ep("string", vals=esplits)
+ yield alt, g