History of airports_struc2vec
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: airports_struc2vec 88b29f2
diff --git a/entries/airports_struc2vec/__init__.py b/entries/airports_struc2vec/__init__.py
new file mode 100644
index 0000000..0640218
--- /dev/null
+++ b/entries/airports_struc2vec/__init__.py
@@ -0,0 +1,73 @@
+#! /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 = "Air traffic in Brazil, Europe and the USA (struc2vec, 2016)"
+description = """Three networks of airports connected by commercial flights in 2016, collected by Ribeiro et al. to evaluate the struc2vec node embedding method, as distributed in their repository:
+
+- `brazil`: airports of Brazil, from the data of the National Civil Aviation Agency (ANAC), from January to December 2016;
+- `europe`: airports of Europe, from the data of Eurostat, from January to November 2016;
+- `usa`: airports of the USA, from the data of the Bureau of Transportation Statistics, from January to October 2016.
+
+An undirected edge connects two airports if there were commercial flights between them during the period. Each airport is labeled with its level of activity, by the quartiles of its distribution in each network (so that the four classes have the same size): the number of landings plus takeoffs (Brazil and Europe), or the number of passengers who arrived or departed (USA). The edges are as in the files: `brazil` has 71 self-loops, and `europe` 2; the numbers of edges thus differ slightly from those stated in the paper (1,038 for Brazil). The data do not identify the airports, except presumably for `usa`, whose node identifiers look like the airport identifiers of the Bureau of Transportation Statistics.
+
+The networks have the following properties:
+
+- `id`: the identifier of the airport in the source data.
+- `activity`: the activity class of the airport, from 0 (the 25% most active airports) to 3 (the 25% least active ones); the order is not stated by the source, but is evident from the degrees of the airports in each class."""
+tags = ['Transportation', 'Airport', 'Unweighted', 'Metadata']
+url = 'https://github.com/leoribeiro/struc2vec'
+citation = [('L. F. R. Ribeiro, P. H. P. Saverese, D. R. Figueiredo, "struc2vec: Learning Node Representations from Structural Identity." Proceedings of the 23rd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 385-394 (2017)', 'https://doi.org/10.1145/3097983.3098061')]
+icon_hash = None
+upstream_license = ('MIT', 'https://github.com/leoribeiro/struc2vec/blob/77b4cc63e79a37b1496f340c7772d932038417ec/LICENSE')
+upstream_prefix = 'https://raw.githubusercontent.com/leoribeiro/struc2vec/77b4cc63e79a37b1496f340c7772d932038417ec/graph'
+files = [((f'{alt}-airports.edgelist', f'labels-{alt}-airports.txt'), alt, None)
+ for alt in ['brazil', 'europe', 'usa']]
+
+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 fnames, alt, fmt in files:
+ if alts is not None and alt not in alts:
+ continue
+ with open_upstream_file(name, fnames[1], "r") as f:
+ assert next(f).split() == ["node", "label"]
+ labels = [tuple(int(x) for x in l.split()) for l in f if l.strip()]
+ with open_upstream_file(name, fnames[0], "r") as f:
+ edges = [tuple(int(x) for x in l.split()) for l in f if l.strip()]
+ ids = sorted(i for i, l in labels)
+ index = {x: i for i, x in enumerate(ids)}
+ g = Graph(directed=False)
+ g.add_vertex(len(ids))
+ g.vp.id = g.new_vp("int", vals=ids)
+ g.vp.activity = g.new_vp("int")
+ for i, l in labels:
+ g.vp.activity[index[i]] = l
+ g.add_edge_list([(index[s], index[t]) for s, t in edges])
+ yield alt, g