History of tennis_atp
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/tennis_atp/__init__.py b/entries/tennis_atp/__init__.py
index 78044e5..62515ff 100644
--- a/entries/tennis_atp/__init__.py
+++ b/entries/tennis_atp/__init__.py
@@ -35,7 +35,7 @@ The networks have the following properties:
tags = ['Social', 'Offline', 'Sports', 'Weighted', 'Metadata']
url = 'https://drive.google.com/drive/folders/1mCxZfkkpIC9o-nxZ1yW3GBBdvBOPW6mQ'
citation = [('U. Michieli, "Complex network analysis of men single ATP tennis matches." arXiv:1804.08138 (2018)', 'https://doi.org/10.48550/arXiv.1804.08138')]
-icon_hash = '5b514faedfd5c2fc3b071847'
+date_added = '2026-10-25'
upstream_license = None
upstream_prefix = 'gdrive://'
files = [('1R0Ci4yFqTJQnEXyxDzz1_T02RPuf4oFO', 'wins', None), # 1_direct_wins.mat
[entries] Prefix the properties in the descriptions with (Node), (Edge) or (Graph) 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/tennis_atp/__init__.py b/entries/tennis_atp/__init__.py
index 23c1462..78044e5 100644
--- a/entries/tennis_atp/__init__.py
+++ b/entries/tennis_atp/__init__.py
@@ -30,8 +30,8 @@ An undirected and unweighted version of `wins` (where an edge connects two playe
The networks have the following properties:
-- `name`: the player's name, as "Surname I." (`wins`, `points`) or "Firstname Surname" (`extended`).
-- `weight`: the number of wins (`wins`) or the ATP points (`points`)."""
+- (Node) `name`: the player's name, as "Surname I." (`wins`, `points`) or "Firstname Surname" (`extended`).
+- (Edge) `weight`: the number of wins (`wins`) or the ATP points (`points`)."""
tags = ['Social', 'Offline', 'Sports', 'Weighted', 'Metadata']
url = 'https://drive.google.com/drive/folders/1mCxZfkkpIC9o-nxZ1yW3GBBdvBOPW6mQ'
citation = [('U. Michieli, "Complex network analysis of men single ATP tennis matches." arXiv:1804.08138 (2018)', 'https://doi.org/10.48550/arXiv.1804.08138')]
[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/tennis_atp/__init__.py b/entries/tennis_atp/__init__.py
index f9ec7a6..23c1462 100644
--- a/entries/tennis_atp/__init__.py
+++ b/entries/tennis_atp/__init__.py
@@ -65,7 +65,6 @@ def mcos_strings(m, n):
@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: tennis_atp c03f7cc
diff --git a/entries/tennis_atp/__init__.py b/entries/tennis_atp/__init__.py
new file mode 100644
index 0000000..f9ec7a6
--- /dev/null
+++ b/entries/tennis_atp/__init__.py
@@ -0,0 +1,93 @@
+#! /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 *
+from scipy.io import loadmat
+
+title = "ATP men's singles tennis matches (1968-2018)"
+description = r"""Networks of the men's singles tennis matches of the Association of Tennis Professionals (ATP), built by U. Michieli from the match records compiled by J. Sackmann (https://github.com/JeffSackmann/tennis_atp). Nodes are players.
+
+- `wins`: matches of the main ATP tour from 1968 to the end of August 2017. A directed edge $i\to j$ goes from a losing player $i$ to a winning player $j$, with `weight` equal to the number of times $j$ won against $i$ (the weights add up to 151,734 matches).
+- `points`: the same matches and players as `wins`, with ATP ranking points as weights. A directed edge is present in both directions between any two players that met, and, according to the source documentation, the weights are "the respective ATP points awarded" to the two players (the loser of a match also receives points); the weight of $i\to j$ is thus presumably the total of points earned by $j$ in their matches against $i$.
+- `extended`: an undirected and unweighted network, where an edge connects two players who played at least one match against each other between 1968 and the end of March 2018, including also the Davis Cup, and the Challenger and Futures tournaments from 1991 onwards (which are not included in the other two networks).
+
+An undirected and unweighted version of `wins` (where an edge connects two players who met) is also distributed upstream; it is not included here, as it is equivalent to `wins` with the edge directions and weights ignored.
+
+The networks have the following properties:
+
+- `name`: the player's name, as "Surname I." (`wins`, `points`) or "Firstname Surname" (`extended`).
+- `weight`: the number of wins (`wins`) or the ATP points (`points`)."""
+tags = ['Social', 'Offline', 'Sports', 'Weighted', 'Metadata']
+url = 'https://drive.google.com/drive/folders/1mCxZfkkpIC9o-nxZ1yW3GBBdvBOPW6mQ'
+citation = [('U. Michieli, "Complex network analysis of men single ATP tennis matches." arXiv:1804.08138 (2018)', 'https://doi.org/10.48550/arXiv.1804.08138')]
+icon_hash = '5b514faedfd5c2fc3b071847'
+upstream_license = None
+upstream_prefix = 'gdrive://'
+files = [('1R0Ci4yFqTJQnEXyxDzz1_T02RPuf4oFO', 'wins', None), # 1_direct_wins.mat
+ ('1C1kvUzNg66gBroE3aHYmG_I9N_Uyu3_O', 'points', None), # 2_direct_points.mat
+ ('15HpQWWq51dAHpWE6OesoNZpNgwX0F0WK', 'extended', None)] # 4_extended_undirect_unweighted.mat
+
+def fetch_upstream(force=False):
+ return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+ force)
+
+def mcos_strings(m, n):
+ """Decode a MATLAB string array of length `n`, which is stored as an opaque
+ object in the "function workspace" of a MAT file: an array of uint64
+ numbers [1, 2, n, 1, length_1, ..., length_n] followed by the
+ concatenated characters in UTF-16."""
+ b = m["__function_workspace__"].tobytes()
+ p = b.find(numpy.array([1, 2, n, 1], dtype="<u8").tobytes())
+ if p < 0:
+ raise ValueError("string array not found")
+ lens = numpy.frombuffer(b[p + 32:p + 32 + 8 * n], dtype="<u8").astype("int64")
+ start = p + 32 + 8 * n
+ s = b[start:start + 2 * lens.sum()].decode("utf-16-le")
+ off = numpy.concatenate([[0], numpy.cumsum(lens)])
+ return [s[off[i]:off[i + 1]] for i in range(n)]
+
+@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", seekable=True) as f:
+ m = loadmat(f)
+ if alt == "extended":
+ A = m["x"].tocoo()
+ N = A.shape[0]
+ g = Graph(directed=False)
+ g.add_vertex(N)
+ idx = A.row < A.col
+ g.add_edge_list(numpy.column_stack((A.row[idx], A.col[idx])))
+ names = [str(x[0]) for x in m["ids"].ravel()]
+ else:
+ A = m["A"]
+ N = A.shape[0]
+ g = Graph(directed=True)
+ g.add_vertex(N)
+ i, j = numpy.nonzero(A)
+ g.ep.weight = g.new_ep("int" if alt == "wins" else "double")
+ g.add_edge_list(numpy.column_stack((i, j, A[i, j])), eprops=[g.ep.weight])
+ names = mcos_strings(m, N)
+ g.vp.name = g.new_vp("string", vals=names)
+ yield alt, g