History of ogbl_citation2
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_citation2/__init__.py b/entries/ogbl_citation2/__init__.py
index 7806040..ed8955c 100644
--- a/entries/ogbl_citation2/__init__.py
+++ b/entries/ogbl_citation2/__init__.py
@@ -44,7 +44,7 @@ url = ['https://ogb.stanford.edu/docs/linkprop/#ogbl-citation2',
'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'),
('K. Wang, Z. Shen, C. Huang, C.-H. Wu, Y. Dong, A. Kanakia, "Microsoft Academic Graph: When experts are not enough." Quantitative Science Studies 1(1), 396-413 (2020)', 'https://doi.org/10.1162/qss_a_00021')]
-icon_hash = None
+date_added = '2026-10-27'
upstream_license = ('ODC-BY 1.0', 'https://opendatacommons.org/licenses/by/1-0/')
upstream_prefix = 'https://snap.stanford.edu/ogb/data'
z = 'linkproppred/citation-v2.zip:citation-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_citation2/__init__.py b/entries/ogbl_citation2/__init__.py
index f8a4918..7806040 100644
--- a/entries/ogbl_citation2/__init__.py
+++ b/entries/ogbl_citation2/__init__.py
@@ -35,10 +35,10 @@ Each paper also has the node features of the benchmark: a 128-dimensional vector
The network has the following properties:
-- `mag_id`: the identifier of the paper in the Microsoft Academic Graph.
-- `year`: the publication year of the paper.
-- `features`: the 128-dimensional feature vector of the paper (the average of the word2vec embeddings of the words of its title and abstract).
-- Edge `split`: the part of the benchmark the citation belongs to: `train`, `valid` or `test`."""
+- (Node) `mag_id`: the identifier of the paper in the Microsoft Academic Graph.
+- (Node) `year`: the publication year of the paper.
+- (Node) `features`: the 128-dimensional feature vector of the paper (the average of the word2vec embeddings of the words of its title and abstract).
+- (Edge) `split`: the part of the benchmark the citation belongs to: `train`, `valid` or `test`."""
tags = ['Informational', 'Citation', 'Unweighted', 'Metadata']
url = ['https://ogb.stanford.edu/docs/linkprop/#ogbl-citation2',
'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_citation2/__init__.py b/entries/ogbl_citation2/__init__.py
index a88723f..f8a4918 100644
--- a/entries/ogbl_citation2/__init__.py
+++ b/entries/ogbl_citation2/__init__.py
@@ -109,7 +109,6 @@ def set_features(g, name, fname, n):
@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_citation2 450f38e
diff --git a/entries/ogbl_citation2/__init__.py b/entries/ogbl_citation2/__init__.py
new file mode 100644
index 0000000..a88723f
--- /dev/null
+++ b/entries/ogbl_citation2/__init__.py
@@ -0,0 +1,137 @@
+#! /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 pickle
+import pandas
+import pyarrow
+import pyarrow.csv
+
+from .. import *
+
+
+title = "Microsoft Academic Graph citations (ogbl-citation2, 2020)"
+description = """A directed citation network of papers of the Microsoft Academic Graph (MAG), from the `ogbl-citation2` dataset of the Open Graph Benchmark (OGB), a benchmark for link prediction (version 1, of December 2020). The papers are a subset of MAG, and an edge from paper A to paper B means that A cites B.
+
+For the benchmark, two references of each of the most recent papers (published in 2019) are held out, one for validation and one for testing (86,596 references each); these held-out citations are included here, so that the network contains all the 30,561,187 citations of the dataset, and they are marked by an edge property.
+
+Each paper also has the node features of the benchmark: a 128-dimensional vector obtained by averaging the word2vec embeddings of the words in its title and abstract (the embeddings were trained by the OGB authors on the MAG corpus). The negative samples of the benchmark (references that do not exist) are also left out. The data do not include the titles of the papers.
+
+The network has the following properties:
+
+- `mag_id`: the identifier of the paper in the Microsoft Academic Graph.
+- `year`: the publication year of the paper.
+- `features`: the 128-dimensional feature vector of the paper (the average of the word2vec embeddings of the words of its title and abstract).
+- Edge `split`: the part of the benchmark the citation belongs to: `train`, `valid` or `test`."""
+tags = ['Informational', 'Citation', 'Unweighted', 'Metadata']
+url = ['https://ogb.stanford.edu/docs/linkprop/#ogbl-citation2',
+ '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'),
+ ('K. Wang, Z. Shen, C. Huang, C.-H. Wu, Y. Dong, A. Kanakia, "Microsoft Academic Graph: When experts are not enough." Quantitative Science Studies 1(1), 396-413 (2020)', 'https://doi.org/10.1162/qss_a_00021')]
+icon_hash = None
+upstream_license = ('ODC-BY 1.0', 'https://opendatacommons.org/licenses/by/1-0/')
+upstream_prefix = 'https://snap.stanford.edu/ogb/data'
+z = 'linkproppred/citation-v2.zip:citation-v2'
+files = [((f'{z}/raw/edge.csv.gz', f'{z}/raw/node_year.csv.gz',
+ f'{z}/mapping/nodeidx2paperid.csv.gz',
+ f'{z}/split/time/valid.pt:zip:archive/data.pkl',
+ f'{z}/split/time/test.pt:zip:archive/data.pkl',
+ f'{z}/raw/node-feat.csv.gz'),
+ None, None)]
+
+def fetch_upstream(force=False):
+ return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+ force)
+
+def read_csv_gz(name, fname, header=None):
+ "The gzipped CSV member `fname`, as an integer array."
+ with open_upstream_file(name, fname, "rb") as f:
+ return pandas.read_csv(f, compression="gzip", header=header,
+ dtype="int64").values
+
+class ArrayUnpickler(pickle.Unpickler):
+ """Unpickles only numpy arrays (and dicts of them), and nothing else: the
+ splits are dicts of numpy arrays, saved by torch.save()."""
+ allowed = {("numpy.core.multiarray", "_reconstruct"),
+ ("numpy._core.multiarray", "_reconstruct"),
+ ("numpy", "ndarray"), ("numpy", "dtype"), ("_codecs", "encode")}
+ def find_class(self, module, name):
+ if (module, name) not in self.allowed:
+ raise pickle.UnpicklingError(f"forbidden: {module}.{name}")
+ return super().find_class(module, name)
+
+def read_split(name, fname):
+ "The (source, target) edges of a held-out split."
+ with open_upstream_file(name, fname, "rb") as f:
+ d = ArrayUnpickler(f).load()
+ return numpy.column_stack([d["source_node"], d["target_node"]])
+
+def set_features(g, name, fname, n):
+ """Store the node features of the gzipped CSV member `fname` (one line of
+ 128 numbers per node, for the first `n` vertices) as the vector<double>
+ vertex property `features`, read in blocks."""
+ p = g.new_vp("vector<double>")
+ i = 0
+ with open_upstream_file(name, fname, "rb") as f, gzip.open(f) as gf:
+ reader = pyarrow.csv.open_csv(
+ gf,
+ read_options=pyarrow.csv.ReadOptions(autogenerate_column_names=True,
+ block_size=1 << 26),
+ convert_options=pyarrow.csv.ConvertOptions(
+ column_types={f"f{j}": pyarrow.float64() for j in range(128)}))
+ for batch in reader:
+ assert batch.num_columns == 128 and i + batch.num_rows <= n
+ x = numpy.column_stack([c.to_numpy() for c in batch.columns])
+ for row in x:
+ p[i] = row
+ i += 1
+ del x
+ assert i == n, (i, n)
+ g.vp.features = p
+
+@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
+ years = read_csv_gz(name, fnames[1])[:, 0]
+ ids = read_csv_gz(name, fnames[2], header=0)
+ N = len(years)
+ assert len(ids) == N and (ids[:, 0] == numpy.arange(N)).all()
+
+ g = Graph(directed=True)
+ g.add_vertex(N)
+ g.vp.mag_id = g.new_vp("int64_t", vals=ids[:, 1])
+ g.vp.year = g.new_vp("int", vals=years)
+ del ids, years
+ set_features(g, name, fnames[5], N)
+ # "<citing>,<cited>"
+ g.add_edge_list(read_csv_gz(name, fnames[0]))
+ E = g.num_edges()
+ valid = read_split(name, fnames[3])
+ g.add_edge_list(valid)
+ test = read_split(name, fnames[4])
+ g.add_edge_list(test)
+ g.ep.split = g.new_ep("string", vals=["train"] * E + ["valid"] * len(valid) +
+ ["test"] * len(test))
+ yield alt, g