logo Netzschleuder network catalog, repository, and centrifuge

History of wikipedia_article_networks

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] New entry: wikipedia_article_networks by Tiago de Paula Peixoto 18a2dd7
diff --git a/entries/wikipedia_article_networks/__init__.py b/entries/wikipedia_article_networks/__init__.py
new file mode 100644
index 0000000..7ecbd9f
--- /dev/null
+++ b/entries/wikipedia_article_networks/__init__.py
@@ -0,0 +1,80 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2020-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/>.
+
+
+from .. import *
+
+import csv
+import json
+
+title = "Wikipedia article networks on chameleons, crocodiles and squirrels (2018)"
+description = r"""Networks of articles of the English Wikipedia on three topics (chameleons, crocodiles and squirrels), collected in December 2018 by B. Rozemberczki and collaborators (MUSAE study) for benchmarks of node embedding and regression methods. Nodes are articles, and an undirected edge connects two articles that link to each other. The article titles were replaced by consecutive indices. Each article has a list of binary features, each marking the presence of an informative noun in its text (only the indices of the features are given, not the nouns), and its average monthly traffic between October 2017 and November 2018, which is the target of the regression task proposed with the data.
+
+There are three networks, `chameleon`, `crocodile` and `squirrel`. The upstream edge lists contain some pairs of articles twice, once in each direction; they are merged into a single undirected edge, which gives the numbers of edges stated by the authors. A few articles are linked to themselves (self-loops), as given in the data.
+
+The networks have the following properties:
+
+- `traffic`: the average monthly traffic of the article (October 2017 to November 2018).
+- `features`: the indices of the article's binary (noun) features."""
+tags = ['Informational', 'Web graph', 'Unweighted', 'Metadata']
+url = ['https://snap.stanford.edu/data/wikipedia-article-networks.html',
+       'https://github.com/benedekrozemberczki/datasets']
+citation = [('B. Rozemberczki, C. Allen, and R. Sarkar, "Multi-scale attributed node embedding." Journal of Complex Networks 9(2), cnab014 (2021).', 'https://doi.org/10.1093/comnet/cnab014')]
+icon_hash = None
+upstream_license = ('MIT License', 'https://github.com/benedekrozemberczki/datasets/blob/3b19135105432cbca65765c1113b91c395ed9d44/LICENSE')
+upstream_prefix = 'https://snap.stanford.edu/data'
+topics = ['chameleon', 'crocodile', 'squirrel']
+files = [((f'wikipedia.zip:wikipedia/{t}/musae_{t}_edges.csv',
+           f'wikipedia.zip:wikipedia/{t}/musae_{t}_target.csv',
+           f'wikipedia.zip:wikipedia/{t}/musae_{t}_features.json'), t, None)
+         for t in topics]
+
+def fetch_upstream(force=False):
+    return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+                                force)
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+    name = __name__.split(".")[-1]
+    for fnames, alt, fmt in files:
+        if alts is not None and alt not in alts:
+            continue
+        with open_upstream_file(name, fnames[0], "rb") as f:
+            E = numpy.loadtxt(f, delimiter=",", skiprows=1, dtype="int64")
+        with open_upstream_file(name, fnames[1], "r") as f:
+            rows = list(csv.DictReader(f))
+        N = len(rows)
+        assert sorted(int(r["id"]) for r in rows) == list(range(N))
+        assert E.max() < N
+        # pairs given in both directions are a single undirected edge
+        E = numpy.unique(numpy.sort(E, axis=1), axis=0)
+        g = Graph(directed=False)
+        g.add_vertex(N)
+        g.add_edge_list(E)
+        g.vp.traffic = g.new_vp("int64_t")
+        for r in rows:
+            g.vp.traffic[int(r["id"])] = int(r["target"])
+        with open_upstream_file(name, fnames[2], "r") as f:
+            feats = json.load(f)
+        assert len(feats) == N
+        g.vp.features = g.new_vp("vector<int32_t>")
+        for v, x in feats.items():
+            g.vp.features[int(v)] = x
+        yield alt, g