logo Netzschleuder network catalog, repository, and centrifuge

History of football_league_results

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: football_league_results by Tiago de Paula Peixoto ef68eed
diff --git a/entries/football_league_results/__init__.py b/entries/football_league_results/__init__.py
new file mode 100644
index 0000000..5138d98
--- /dev/null
+++ b/entries/football_league_results/__init__.py
@@ -0,0 +1,67 @@
+#! /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 = 'Football league results (2013-2017)'
+description = """Results of the games of four national football (soccer) leagues, one network per season, compiled by hand from Wikipedia by Fanuel and Suykens, as distributed by KONECT:
+
+- `be1_2016`: Belgian Pro League, season 2016/2017;
+- `de1_2016`: German Bundesliga, season 2016/2017;
+- `fr1_2016`: French Ligue 1, season 2016/2017;
+- `uk1_2013`: English Premier League, season 2013/2014.
+
+Each node is a team, and a directed edge from team A to team B is a game that A played at home against B. The edges are signed by the goal difference (positive if the home team won, negative if it lost, zero for a draw); the scores of the games are not included. Only the games of the regular seasons are included (in `be1_2016`, 239 of the 240 games of the regular season; one is missing). The data identify the teams only by indices (their names are not included).
+
+The networks have the following properties:
+
+- Edge `goal_difference`: the goals of the home team minus the goals of the away team."""
+tags = ['Social', 'Offline', 'Sports', 'Signed', 'Weighted']
+url = ['http://konect.cc/networks/league-be1-2016', 'http://konect.cc/networks/league-de1-2016', 'http://konect.cc/networks/league-fr1-2016', 'http://konect.cc/networks/league-uk1-2013']
+citation = [('M. Fanuel, J. A. K. Suykens, "Deformed Laplacians and spectral ranking in directed networks." Applied and Computational Harmonic Analysis 47(2), 397-422 (2019)', 'https://doi.org/10.1016/j.acha.2017.09.002'),
+            ('J. Kunegis, "KONECT -- The Koblenz Network Collection." Proceedings of the 22nd International Conference on World Wide Web Companion, 1343-1350 (2013)', 'https://doi.org/10.1145/2487788.2488173')]
+icon_hash = None
+upstream_license = None
+upstream_prefix = 'http://konect.cc/files'
+files = [(f'download.tsv.league-{l}.tar.bz2', l.replace('-', '_'), 'konect')
+         for l in ['be1-2016', 'de1-2016', 'fr1-2016', 'uk1-2013']]
+
+def postprocess(alt, g):
+    g.ep.goal_difference = g.ep.weight.copy("int")
+    del g.ep["weight"]
+
+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
+        with open_upstream_file(name, fname, "rb") as f:
+            g = parse_graph([f], fmt, directed=None)
+        postprocess(alt, g)
+        yield alt, g