History of topcoder_epidemic
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/topcoder_epidemic/__init__.py b/entries/topcoder_epidemic/__init__.py
index 57e088c..99c98b2 100644
--- a/entries/topcoder_epidemic/__init__.py
+++ b/entries/topcoder_epidemic/__init__.py
@@ -23,7 +23,7 @@ description = """An undirected network of friendships from an unidentified onlin
tags = ['Social', 'Online', 'Unweighted']
url = 'https://web.archive.org/web/20100614043427/http://networkdata.ics.uci.edu/data.php?d=topcoder'
citation = [('C. DuBois, P. Smyth, "Social network from TopCoder\'s Epidemic contest", UCI Network Data Repository, University of California, Irvine (2008)', 'https://web.archive.org/web/20100614043427/http://networkdata.ics.uci.edu/data.php?d=topcoder')]
-icon_hash = '584999778cf714f319c48f8b'
+date_added = '2026-10-25'
upstream_license = None
# The UCI Network Data Repository is offline; the file is obtained from the
# Internet Archive.
[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/topcoder_epidemic/__init__.py b/entries/topcoder_epidemic/__init__.py
index 295d539..57e088c 100644
--- a/entries/topcoder_epidemic/__init__.py
+++ b/entries/topcoder_epidemic/__init__.py
@@ -38,7 +38,6 @@ def fetch_upstream(force=False):
@coerce_props()
@annotate()
def parse(alts=None):
- global files
name = __name__.split(".")[-1]
for fname, alt, fmt in files:
if alts is not None and alt not in alts:
[entries] New entry: topcoder_epidemic 523f9e8
diff --git a/entries/topcoder_epidemic/__init__.py b/entries/topcoder_epidemic/__init__.py
new file mode 100644
index 0000000..295d539
--- /dev/null
+++ b/entries/topcoder_epidemic/__init__.py
@@ -0,0 +1,69 @@
+#! /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 = "TopCoder Epidemic contest social network (2008)"
+description = """An undirected network of friendships from an unidentified online social networking site, used for the "Epidemic" programming contest held at TopCoder.com in April 2008, and provided by L. Backstrom to the UCI Network Data Repository. Nodes are users of the site, and an undirected edge connects two users who are friends. In the contest, participants had to find strategies to optimally slow down the spread of a simulated epidemic along networks sampled from this one (the sampled example graphs are not included here). The name of the site and the date of collection are not documented, and the nodes carry no metadata."""
+tags = ['Social', 'Online', 'Unweighted']
+url = 'https://web.archive.org/web/20100614043427/http://networkdata.ics.uci.edu/data.php?d=topcoder'
+citation = [('C. DuBois, P. Smyth, "Social network from TopCoder\'s Epidemic contest", UCI Network Data Repository, University of California, Irvine (2008)', 'https://web.archive.org/web/20100614043427/http://networkdata.ics.uci.edu/data.php?d=topcoder')]
+icon_hash = '584999778cf714f319c48f8b'
+upstream_license = None
+# The UCI Network Data Repository is offline; the file is obtained from the
+# Internet Archive.
+upstream_prefix = 'https://web.archive.org/web/20100614093555id_/http://networkdata.ics.uci.edu/data/topcoder'
+files = [('network.gz', None, None)]
+
+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):
+ global files
+ name = __name__.split(".")[-1]
+ for fname, alt, fmt in files:
+ if alts is not None and alt not in alts:
+ continue
+ # The first line holds the degrees of all nodes; line i + 1 holds the
+ # neighbours of node i, each edge appearing in only one of the lists.
+ with open_upstream_file(name, fname, "rb") as f:
+ degs = numpy.array(f.readline().split(), dtype="int64")
+ N = len(degs)
+ counts = numpy.zeros(N, dtype="int64")
+ chunks = []
+ for i, line in enumerate(f):
+ if i >= N:
+ if line.strip():
+ raise ValueError("more edge lists than nodes")
+ continue
+ vs = numpy.array(line.split(), dtype="int64")
+ counts[i] = len(vs)
+ if len(vs) > 0:
+ chunks.append(vs)
+ tgt = numpy.concatenate(chunks)
+ src = numpy.repeat(numpy.arange(N, dtype="int64"), counts)
+ g = Graph(directed=False)
+ g.add_vertex(N)
+ g.add_edge_list(numpy.column_stack((src, tgt)))
+ if not numpy.array_equal(g.get_total_degrees(g.get_vertices()), degs):
+ raise ValueError("degrees do not match the header")
+ yield alt, g