logo Netzschleuder network catalog, repository, and centrifuge

History of erdos_collaboration

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: erdos_collaboration by Tiago de Paula Peixoto bcc4626
diff --git a/entries/erdos_collaboration/__init__.py b/entries/erdos_collaboration/__init__.py
new file mode 100644
index 0000000..e44868a
--- /dev/null
+++ b/entries/erdos_collaboration/__init__.py
@@ -0,0 +1,84 @@
+#! /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/>.
+
+
+
+from .. import *
+
+
+title = "Erdős collaboration graph (1997-2002)"
+description = """Networks of the mathematicians with Erdős number 1 or 2, i.e. the co-authors of Paul Erdős, and the co-authors of these, from the data of the Erdős Number Project of J. W. Grossman, as converted to Pajek networks by V. Batagelj and A. Mrvar, in four versions of the data: `erdos97`, `erdos98`, `erdos99` (from 1997, 1998 and 1999) and `erdos02` (from 2002). Each node is a mathematician, and an undirected edge connects two of them if they wrote a paper together. The data list the co-authors of the people with Erdős number 1 only, so that the edges join people with Erdős number 1, or people with Erdős numbers 1 and 2; there are no edges between people with Erdős number 2. Paul Erdős himself (and his edges to his co-authors) is included only in `erdos02`.
+
+Batagelj and Mrvar also distribute the networks of the people with Erdős number 1 for 1997 to 1999 (e.g. `ERDOS971.NET`); they are not included as separate networks, since they are the subgraphs of the full networks induced by these people.
+
+The networks have the following properties:
+
+- `name`: the name of the mathematician (in upper case, except in `erdos97` and for a few names of `erdos02`).
+- `erdos_number`: the Erdős number of the mathematician (0 for Paul Erdős, 1 or 2 otherwise). For `erdos97` to `erdos99` they are given by the partitions distributed with the networks; for `erdos02` they follow from the network."""
+tags = ['Social', 'Collaboration', 'Unweighted', 'Metadata']
+url = ['https://web.archive.org/web/20041128004146/http://vlado.fmf.uni-lj.si/pub/networks/data/default.htm',
+       'https://oakland.edu/enp/']
+citation = [('V. Batagelj, A. Mrvar, "Some analyses of Erdős collaboration graph." Social Networks 22(2), 173-186 (2000)', 'https://doi.org/10.1016/S0378-8733(00)00023-X'),
+            ('J. W. Grossman, P. D. F. Ion, "On a portion of the well-known collaboration graph." Congressus Numerantium 108, 129-131 (1995)', 'https://oakland.edu/enp/')]
+icon_hash = None
+upstream_license = None
+upstream_prefix = None
+
+archived_files = {
+    'ERDOSdat.ZIP': 'https://web.archive.org/web/20041222053355id_/http://vlado.fmf.uni-lj.si:80/pub/networks/data/erdos/ERDOSdat.ZIP',
+    'Erdos02.net': 'https://web.archive.org/web/20041220213354id_/http://vlado.fmf.uni-lj.si:80/pub/networks/data/Erdos/Erdos02.net'}
+files = [((f'ERDOSdat.ZIP:zip:ERDOS{y}2.NET', f'ERDOSdat.ZIP:zip:ERDOS{y}.CLU'),
+          f'erdos{y}', None) for y in ['97', '98', '99']]
+files += [(('Erdos02.net',), 'erdos02', None)]
+
+def fetch_upstream(force=False):
+    return fetch_archived_files(__name__.split(".")[-1], archived_files, force,
+                                tries=3)
+
+@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
+        net = get_pajek_item(load_pajek(name, fnames[0]), "network")
+        g = pajek_graph(net)
+        g.vp.erdos_number = g.new_vp("int")
+        if len(fnames) > 1:
+            # "*Vertices N" and then one value per vertex: 1 for Erdős
+            # number 1, 0 for Erdős number 2
+            with open_upstream_file(name, fnames[1], "r", encoding="cp1252") as f:
+                vals = f.read().split()
+            assert vals[0].lower() == "*vertices" and int(vals[1]) == g.num_vertices()
+            clu = numpy.array([int(x) for x in vals[2:]])
+            # the partition of 1998 has an extra (last) value, 0
+            if len(clu) == g.num_vertices() + 1 and clu[-1] == 0:
+                clu = clu[:-1]
+            assert len(clu) == g.num_vertices() and set(clu) <= {0, 1}
+            g.vp.erdos_number.a = 2 - clu
+        else:
+            erdos = [v for v in g.vertices() if g.vp.name[v].upper() == "ERDOS PAUL"]
+            assert len(erdos) == 1
+            g.vp.erdos_number.a = 2
+            g.vp.erdos_number[erdos[0]] = 0
+            for u in erdos[0].all_neighbors():
+                g.vp.erdos_number[u] = 1
+        yield alt, g