logo Netzschleuder network catalog, repository, and centrifuge

History of wiki_cs_links

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/wiki_cs_links/__init__.py b/entries/wiki_cs_links/__init__.py
index 7ceec93..4eb7cf9 100644
--- a/entries/wiki_cs_links/__init__.py
+++ b/entries/wiki_cs_links/__init__.py
@@ -37,7 +37,7 @@ tags = ['Informational', 'Web graph', 'Unweighted', 'Multigraph', 'Metadata']
 url = ['https://web.archive.org/web/20150109222641/http://arnetminer.org/lab-datasets/ltg/',
        'https://lfs.aminer.cn/lab-datasets/ltg/']
 citation = [('J. Tang, J. Zhang, J. X. Yu, Z. Yang, K. Cai, R. Ma, L. Zhang, Z. Su, "Topic distributions over links on web." Ninth IEEE International Conference on Data Mining (ICDM), 1010-1015 (2009)', 'https://doi.org/10.1109/ICDM.2009.116')]
-icon_hash = '5944b58a4ed8f1bb6022a4a2'
+date_added = '2026-10-25'
 upstream_license = None
 upstream_prefix = 'https://lfs.aminer.cn/lab-datasets/ltg'
 # The rar archive is stored under a name without extension (read directly)
[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/wiki_cs_links/__init__.py b/entries/wiki_cs_links/__init__.py
index dafca90..7ceec93 100644
--- a/entries/wiki_cs_links/__init__.py
+++ b/entries/wiki_cs_links/__init__.py
@@ -28,11 +28,11 @@ The data set also lists the words near the anchor text of each link, which are n
 
 The networks have the following properties:
 
-- `title`: the title of the article (empty for words).
-- `wiki_id` (articles): the identifier of the article in the Wikipedia dump (-1 for words).
-- `label` (`links` edges): the link category, as above.
-- `is_article` (`words`): whether the node is an article (otherwise it is a word).
-- `word` (`words`): the word (empty for articles)."""
+- (Node) `title`: the title of the article (empty for words).
+- (Node) `wiki_id` (articles): the identifier of the article in the Wikipedia dump (-1 for words).
+- (Edge) `label` (`links` edges): the link category, as above.
+- (Node) `is_article` (`words`): whether the node is an article (otherwise it is a word).
+- (Node) `word` (`words`): the word (empty for articles)."""
 tags = ['Informational', 'Web graph', 'Unweighted', 'Multigraph', 'Metadata']
 url = ['https://web.archive.org/web/20150109222641/http://arnetminer.org/lab-datasets/ltg/',
        'https://lfs.aminer.cn/lab-datasets/ltg/']
[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/wiki_cs_links/__init__.py b/entries/wiki_cs_links/__init__.py
index 36987e8..dafca90 100644
--- a/entries/wiki_cs_links/__init__.py
+++ b/entries/wiki_cs_links/__init__.py
@@ -58,7 +58,6 @@ def read_lines(name, fname):
 @coerce_props(vforce={'title': 'string', 'word': 'string'})
 @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: wiki_cs_links by Tiago de Paula Peixoto 8161a15
diff --git a/entries/wiki_cs_links/__init__.py b/entries/wiki_cs_links/__init__.py
new file mode 100644
index 0000000..36987e8
--- /dev/null
+++ b/entries/wiki_cs_links/__init__.py
@@ -0,0 +1,100 @@
+#! /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 *
+
+title = "Wikipedia computer science articles, links and words (2008)"
+description = """Networks of the English Wikipedia articles on computer science, from the dump of October 8, 2008, compiled by J. Tang and colleagues (Tsinghua University) to study the semantics of hyperlinks ("topic distributions over links"), and distributed by AMiner. The data set contains 14,468 articles, starting from "Computer science".
+
+- `links`: hyperlinks between the articles. Nodes are articles, and a directed edge $i \\to j$ is a hyperlink from article $i$ (source) to article $j$ (target). Some article pairs are linked several times, kept as parallel edges (25,817 links between 22,432 pairs). Each link has a `label` giving its annotated category, following the specification of the authors: 0, "drill down" (a link from summary information to detailed information, or to a basic theory used in the source); 1, "similar" (a link between pages with similar content); 2, "other"; the meaning of the label 3, used for 1,138 links, is not documented. Articles without links are isolated nodes.
+- `words`: a bipartite network of articles and the words of their abstracts. Nodes are articles and words, and an undirected edge connects an article to a word contained in its abstract (263,634 edges between 13,972 articles and 26,093 words).
+
+The data set also lists the words near the anchor text of each link, which are not included here.
+
+The networks have the following properties:
+
+- `title`: the title of the article (empty for words).
+- `wiki_id` (articles): the identifier of the article in the Wikipedia dump (-1 for words).
+- `label` (`links` edges): the link category, as above.
+- `is_article` (`words`): whether the node is an article (otherwise it is a word).
+- `word` (`words`): the word (empty for articles)."""
+tags = ['Informational', 'Web graph', 'Unweighted', 'Multigraph', 'Metadata']
+url = ['https://web.archive.org/web/20150109222641/http://arnetminer.org/lab-datasets/ltg/',
+       'https://lfs.aminer.cn/lab-datasets/ltg/']
+citation = [('J. Tang, J. Zhang, J. X. Yu, Z. Yang, K. Cai, R. Ma, L. Zhang, Z. Su, "Topic distributions over links on web." Ninth IEEE International Conference on Data Mining (ICDM), 1010-1015 (2009)', 'https://doi.org/10.1109/ICDM.2009.116')]
+icon_hash = '5944b58a4ed8f1bb6022a4a2'
+upstream_license = None
+upstream_prefix = 'https://lfs.aminer.cn/lab-datasets/ltg'
+# The rar archive is stored under a name without extension (read directly)
+files = [(('enwiki:rar:enwiki/pair_doc', 'enwiki:rar:enwiki/pair_label',
+           'enwiki:rar:enwiki/docmap'), 'links', None),
+         (('enwiki:rar:enwiki/doc_words', 'enwiki:rar:enwiki/docmap',
+           'enwiki:rar:enwiki/wordmap'), 'words', None)]
+archived_urls = {'enwiki:rar:enwiki/README.txt': f'{upstream_prefix}/enwiki.rar'}
+
+def fetch_upstream(force=False):
+    return fetch_archived_files(__name__.split(".")[-1], archived_urls, force)
+
+def read_lines(name, fname):
+    with open_upstream_file(name, fname, "rb") as f:
+        return f.read().decode("utf-8", "replace").splitlines()
+
+@cache_network()
+@coerce_props(vforce={'title': 'string', 'word': 'string'})
+@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
+        # docmap: line k (from 1) is article k, "wikipedia id \t title"
+        docs = [l.split("\t", 1)
+                for l in read_lines(name, fnames[2 if alt == "links" else 1])
+                if l.strip()]
+        if alt == "links":
+            pairs = [l.split() for l in read_lines(name, fnames[0]) if l.strip()]
+            labels = [int(l) for l in read_lines(name, fnames[1]) if l.strip()]
+            g = Graph(directed=True)
+            g.add_vertex(len(docs))
+            g.ep.label = g.new_ep("int")
+            g.add_edge_list([(int(s) - 1, int(t) - 1, c)
+                             for (s, t), c in zip(pairs, labels)],
+                            eprops=[g.ep.label])
+            g.vp.title = g.new_vp("string", vals=[d[1] if len(d) > 1 else ""
+                                                   for d in docs])
+            g.vp.wiki_id = g.new_vp("int", vals=[int(d[0]) for d in docs])
+        else:
+            words = read_lines(name, fnames[2])
+            dw = [l.split() for l in read_lines(name, fnames[0]) if l.strip()]
+            darts = sorted(set(int(x[0]) for x in dw))
+            dwords = sorted(set(int(x[1]) for x in dw))
+            aidx = {a: k for k, a in enumerate(darts)}
+            widx = {w: len(darts) + k for k, w in enumerate(dwords)}
+            g = Graph(directed=False)
+            g.add_vertex(len(darts) + len(dwords))
+            g.add_edge_list([(aidx[int(x[0])], widx[int(x[1])]) for x in dw])
+            g.vp.is_article = g.new_vp("bool")
+            g.vp.is_article.a[:len(darts)] = 1
+            g.vp.title = g.new_vp("string", vals=[docs[a - 1][1] if len(docs[a - 1]) > 1 else ""
+                                                   for a in darts] + [""] * len(dwords))
+            g.vp.wiki_id = g.new_vp("int", vals=[int(docs[a - 1][0]) for a in darts]
+                                    + [-1] * len(dwords))
+            g.vp.word = g.new_vp("string", vals=[""] * len(darts) +
+                                 [words[w - 1].strip() for w in dwords])
+        yield alt, g