logo Netzschleuder network catalog, repository, and centrifuge

History of ogbn_arxiv

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 by Tiago de Paula Peixoto 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/ogbn_arxiv/__init__.py b/entries/ogbn_arxiv/__init__.py
index 3d4172b..e3d5d97 100644
--- a/entries/ogbn_arxiv/__init__.py
+++ b/entries/ogbn_arxiv/__init__.py
@@ -42,7 +42,7 @@ url = ['https://ogb.stanford.edu/docs/nodeprop/#ogbn-arxiv',
        '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'
 files = [(('nodeproppred/arxiv.zip:arxiv/raw/edge.csv.gz',
[entries] Prefix the properties in the descriptions with (Node), (Edge) or (Graph) by Tiago de Paula Peixoto 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/ogbn_arxiv/__init__.py b/entries/ogbn_arxiv/__init__.py
index ce82f91..3d4172b 100644
--- a/entries/ogbn_arxiv/__init__.py
+++ b/entries/ogbn_arxiv/__init__.py
@@ -32,11 +32,11 @@ 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.
-- `title`: the title of the paper, normalized.
-- `year`: the publication year of the paper.
-- `subject`: the primary arXiv subject area of the paper, e.g. `cs.LG` or `cs.AI`.
-- `features`: the 128-dimensional feature vector of the paper (the average of the word2vec embeddings of the words of its title and abstract)."""
+- (Node) `mag_id`: the identifier of the paper in the Microsoft Academic Graph.
+- (Node) `title`: the title of the paper, normalized.
+- (Node) `year`: the publication year of the paper.
+- (Node) `subject`: the primary arXiv subject area of the paper, e.g. `cs.LG` or `cs.AI`.
+- (Node) `features`: the 128-dimensional feature vector of the paper (the average of the word2vec embeddings of the words of its title and abstract)."""
 tags = ['Informational', 'Citation', 'Unweighted', 'Metadata']
 url = ['https://ogb.stanford.edu/docs/nodeprop/#ogbn-arxiv',
        'https://snap.stanford.edu/ogb/data/']
[entries] Remove unneeded code from the entries by Tiago de Paula Peixoto 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/ogbn_arxiv/__init__.py b/entries/ogbn_arxiv/__init__.py
index f650687..ce82f91 100644
--- a/entries/ogbn_arxiv/__init__.py
+++ b/entries/ogbn_arxiv/__init__.py
@@ -91,7 +91,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: ogbn_arxiv by Tiago de Paula Peixoto f8a8223
diff --git a/entries/ogbn_arxiv/__init__.py b/entries/ogbn_arxiv/__init__.py
new file mode 100644
index 0000000..f650687
--- /dev/null
+++ b/entries/ogbn_arxiv/__init__.py
@@ -0,0 +1,138 @@
+#! /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 pyarrow
+import pyarrow.csv
+
+from .. import *
+
+
+title = "arXiv computer science citations (ogbn-arxiv, 1971-2020)"
+description = """A directed citation network of the computer science papers of the arXiv preprint server, as indexed by the Microsoft Academic Graph (MAG), from the `ogbn-arxiv` dataset of the Open Graph Benchmark (OGB), a benchmark for node classification (version 1, of May 2020). Each paper is labeled with its primary arXiv subject area (one of the 40 computer science categories, chosen by the authors and the arXiv moderators), and the publication years range from 1971 to 2020.
+
+An edge from paper A to paper B means that A cites B. There are no self-loops, and 8,444 pairs of papers cite each other.
+
+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 titles of the papers come from a separate file of the OGB authors, which also has their abstracts (left out). The titles are as normalized by MAG (in lower case, without punctuation).
+
+The network has the following properties:
+
+- `mag_id`: the identifier of the paper in the Microsoft Academic Graph.
+- `title`: the title of the paper, normalized.
+- `year`: the publication year of the paper.
+- `subject`: the primary arXiv subject area of the paper, e.g. `cs.LG` or `cs.AI`.
+- `features`: the 128-dimensional feature vector of the paper (the average of the word2vec embeddings of the words of its title and abstract)."""
+tags = ['Informational', 'Citation', 'Unweighted', 'Metadata']
+url = ['https://ogb.stanford.edu/docs/nodeprop/#ogbn-arxiv',
+       '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'
+files = [(('nodeproppred/arxiv.zip:arxiv/raw/edge.csv.gz',
+           'nodeproppred/arxiv.zip:arxiv/raw/node_year.csv.gz',
+           'nodeproppred/arxiv.zip:arxiv/raw/node-label.csv.gz',
+           'nodeproppred/arxiv.zip:arxiv/mapping/labelidx2arxivcategeory.csv.gz',
+           'nodeproppred/arxiv.zip:arxiv/mapping/nodeidx2paperid.csv.gz',
+           'misc/ogbn_arxiv/titleabs.tsv.gz:tar:titleabs.tsv',
+           'nodeproppred/arxiv.zip:arxiv/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):
+    "The lines of the gzipped CSV member `fname`."
+    with open_upstream_file(name, fname, "rb") as f:
+        with gzip.open(f, "rt") as gf:
+            return gf.read().splitlines()
+
+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
+        edges = numpy.array([l.split(",") for l in read_csv_gz(name, fnames[0])],
+                            dtype=numpy.int64)
+        years = [int(l) for l in read_csv_gz(name, fnames[1])]
+        labels = [int(l) for l in read_csv_gz(name, fnames[2])]
+        # "label idx,arxiv category", e.g. "0,arxiv cs na"
+        cats = {}
+        for l in read_csv_gz(name, fnames[3])[1:]:
+            i, c = l.split(",")
+            c = c.split()
+            assert c[:2] == ["arxiv", "cs"], c
+            cats[int(i)] = f"cs.{c[2].upper()}"
+        # "node idx,paper id"
+        mag = {}
+        for l in read_csv_gz(name, fnames[4])[1:]:
+            i, p = l.split(",")
+            mag[int(i)] = int(p)
+        N = len(years)
+        assert len(labels) == N and sorted(mag) == list(range(N))
+
+        # "<MAG id>\t<title>\t<abstract>", for these and other papers
+        mids = set(mag.values())
+        titles = {}
+        with open_upstream_file(name, fnames[5], "r") as f:
+            for line in f:
+                row = line.rstrip("\n").split("\t")
+                if len(row) < 2 or not row[0].isdigit():
+                    continue
+                if int(row[0]) in mids:
+                    titles[int(row[0])] = row[1]
+
+        g = Graph(directed=True)
+        g.add_vertex(N)
+        g.vp.mag_id = g.new_vp("int64_t", vals=[mag[i] for i in range(N)])
+        g.vp.title = g.new_vp("string", vals=[titles.get(mag[i], "") for i in range(N)])
+        g.vp.year = g.new_vp("int", vals=years)
+        g.vp.subject = g.new_vp("string", vals=[cats[l] for l in labels])
+        # Edges: "<citing>,<cited>"
+        g.add_edge_list(edges)
+        set_features(g, name, fnames[6], N)
+        yield alt, g