logo Netzschleuder network catalog, repository, and centrifuge

History of foursquare_nyc_tokyo

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] Remove superfluous details of the upstream distribution from the descriptions by Tiago de Paula Peixoto dc07aa0
The descriptions mentioned incidental details of how the upstream data
are made available: the file formats (CSV, JSON, XML, GEXF, SBML, HIF,
Pajek, UCINET, ...), file names, where the files were published or
obtained from (Zenodo, figshare, Kaggle, the Pajek datasets page, the
Internet Archive), and that some networks are only available in the gt
format. These are left out; caveats about the data themselves are kept,
referring to "the data" instead of "the file". The description of
sp_baboons now lists its properties instead of the upstream columns,
and says that events without a recipient are left out.
diff --git a/entries/foursquare_nyc_tokyo/__init__.py b/entries/foursquare_nyc_tokyo/__init__.py
index 27daa94..91772ad 100644
--- a/entries/foursquare_nyc_tokyo/__init__.py
+++ b/entries/foursquare_nyc_tokyo/__init__.py
@@ -39,7 +39,7 @@ The networks have the following properties:
 
 - (Node) `is_user`: whether the node is a user (otherwise it is a venue).
 - (Node) `name`: the anonymized user ID or the Foursquare venue ID.
-- (Node) `category`, `category_id`: the name and Foursquare ID of the fine-grained venue category (e.g. "Bridge", "Home (private)"; empty for users). A few hundred venues have check-ins with different categories; for these, the category of their first check-in in the file is used.
+- (Node) `category`, `category_id`: the name and Foursquare ID of the fine-grained venue category (e.g. "Bridge", "Home (private)"; empty for users). A few hundred venues have check-ins with different categories; for these, the category of their first check-in in the data is used.
 - (Edge) `time`: the time of the check-in (Unix time, UTC).
 - (Edge) `tz_offset`: the offset of the local time with respect to UTC, in minutes.
 - (Edge) `latitude` and `longitude`: the GPS coordinates of the check-in (which may vary slightly between check-ins at the same venue).[^icon].
[entries] Add the date when each entry was added, and remove icon_hash by Tiago de Paula Peixoto 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/foursquare_nyc_tokyo/__init__.py b/entries/foursquare_nyc_tokyo/__init__.py
index c5977bc..27daa94 100644
--- a/entries/foursquare_nyc_tokyo/__init__.py
+++ b/entries/foursquare_nyc_tokyo/__init__.py
@@ -48,7 +48,7 @@ The networks have the following properties:
 tags = ['Social', 'Online', 'Unweighted', 'Metadata', 'Timestamps', 'Multigraph', 'Spatial']
 url = 'https://sites.google.com/site/yangdingqi/home/foursquare-dataset'
 citation = [('D. Yang, D. Zhang, V. W. Zheng, Z. Yu, "Modeling user activity preference by leveraging user spatial temporal characteristics in LBSNs." IEEE Transactions on Systems, Man, and Cybernetics: Systems 45(1), 129-142 (2015)', 'https://doi.org/10.1109/TSMC.2014.2327053')]
-icon_hash = '595b0d1c549f067e0263b50b'
+date_added = '2026-10-25'
 upstream_license = None
 upstream_prefix = 'gdrive://'
 files = [('1VE67jfSN-GV6fkCfuyBEQJzk_qy-SfOk:zip:dataset_tsmc2014/dataset_TSMC2014_NYC.txt', 'NYC', None),
[entries] Prefix the properties in the descriptions with (Node), (Edge) or (Graph) by Tiago de Paula Peixoto 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/foursquare_nyc_tokyo/__init__.py b/entries/foursquare_nyc_tokyo/__init__.py
index 80ba9ed..c5977bc 100644
--- a/entries/foursquare_nyc_tokyo/__init__.py
+++ b/entries/foursquare_nyc_tokyo/__init__.py
@@ -37,8 +37,12 @@ description = """Two bipartite networks of users and venues of the location-base
 
 The networks have the following properties:
 
-- Nodes: `is_user`, whether the node is a user (otherwise it is a venue); `name`, the anonymized user ID or the Foursquare venue ID; `category` and `category_id`, the name and Foursquare ID of the fine-grained venue category (e.g. "Bridge", "Home (private)"; empty for users). A few hundred venues have check-ins with different categories; for these, the category of their first check-in in the file is used.
-- Edges: `time`, the time of the check-in (Unix time, UTC); `tz_offset`, the offset of the local time with respect to UTC, in minutes; `latitude` and `longitude`, the GPS coordinates of the check-in (which may vary slightly between check-ins at the same venue).[^icon]
+- (Node) `is_user`: whether the node is a user (otherwise it is a venue).
+- (Node) `name`: the anonymized user ID or the Foursquare venue ID.
+- (Node) `category`, `category_id`: the name and Foursquare ID of the fine-grained venue category (e.g. "Bridge", "Home (private)"; empty for users). A few hundred venues have check-ins with different categories; for these, the category of their first check-in in the file is used.
+- (Edge) `time`: the time of the check-in (Unix time, UTC).
+- (Edge) `tz_offset`: the offset of the local time with respect to UTC, in minutes.
+- (Edge) `latitude` and `longitude`: the GPS coordinates of the check-in (which may vary slightly between check-ins at the same venue).[^icon].
 
 [^icon]: Description obtained in part from the [ICON](https://icon.colorado.edu) project."""
 tags = ['Social', 'Online', 'Unweighted', 'Metadata', 'Timestamps', 'Multigraph', 'Spatial']
[entries] Remove unneeded code from the entries by Tiago de Paula Peixoto 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/foursquare_nyc_tokyo/__init__.py b/entries/foursquare_nyc_tokyo/__init__.py
index 7733246..80ba9ed 100644
--- a/entries/foursquare_nyc_tokyo/__init__.py
+++ b/entries/foursquare_nyc_tokyo/__init__.py
@@ -58,7 +58,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: foursquare_nyc_tokyo by Tiago de Paula Peixoto e2725b8
diff --git a/entries/foursquare_nyc_tokyo/__init__.py b/entries/foursquare_nyc_tokyo/__init__.py
new file mode 100644
index 0000000..7733246
--- /dev/null
+++ b/entries/foursquare_nyc_tokyo/__init__.py
@@ -0,0 +1,102 @@
+#! /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 *
+import io
+from datetime import datetime, timezone
+
+_months = {m: i + 1 for i, m in enumerate(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+                                            'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'])}
+
+def _utc_time(s):
+    "Unix time of a string like 'Tue Apr 03 18:00:09 +0000 2012' (locale-independent)."
+    _, mon, day, hms, off, year = s.split()
+    assert off == '+0000'
+    h, m, sec = map(int, hms.split(':'))
+    return int(datetime(int(year), _months[mon], int(day), h, m, sec,
+                        tzinfo=timezone.utc).timestamp())
+
+title = "Foursquare check-ins in New York and Tokyo (2012-2013)"
+description = """Two bipartite networks of users and venues of the location-based social network Foursquare, from check-ins in New York City (`NYC`) and Tokyo (`TKY`) collected by D. Yang and collaborators between 12 April 2012 and 16 February 2013 (about ten months). Nodes are users and venues, and an undirected edge is a check-in of a user at a venue, annotated with its time and GPS coordinates; repeated check-ins of the same user at the same venue appear as parallel edges. The `NYC` network contains 227,428 check-ins and the `TKY` network 573,703 check-ins. The data were originally used to study the spatio-temporal regularity of user activities.
+
+The networks have the following properties:
+
+- Nodes: `is_user`, whether the node is a user (otherwise it is a venue); `name`, the anonymized user ID or the Foursquare venue ID; `category` and `category_id`, the name and Foursquare ID of the fine-grained venue category (e.g. "Bridge", "Home (private)"; empty for users). A few hundred venues have check-ins with different categories; for these, the category of their first check-in in the file is used.
+- Edges: `time`, the time of the check-in (Unix time, UTC); `tz_offset`, the offset of the local time with respect to UTC, in minutes; `latitude` and `longitude`, the GPS coordinates of the check-in (which may vary slightly between check-ins at the same venue).[^icon]
+
+[^icon]: Description obtained in part from the [ICON](https://icon.colorado.edu) project."""
+tags = ['Social', 'Online', 'Unweighted', 'Metadata', 'Timestamps', 'Multigraph', 'Spatial']
+url = 'https://sites.google.com/site/yangdingqi/home/foursquare-dataset'
+citation = [('D. Yang, D. Zhang, V. W. Zheng, Z. Yu, "Modeling user activity preference by leveraging user spatial temporal characteristics in LBSNs." IEEE Transactions on Systems, Man, and Cybernetics: Systems 45(1), 129-142 (2015)', 'https://doi.org/10.1109/TSMC.2014.2327053')]
+icon_hash = '595b0d1c549f067e0263b50b'
+upstream_license = None
+upstream_prefix = 'gdrive://'
+files = [('1VE67jfSN-GV6fkCfuyBEQJzk_qy-SfOk:zip:dataset_tsmc2014/dataset_TSMC2014_NYC.txt', 'NYC', None),
+         ('1VE67jfSN-GV6fkCfuyBEQJzk_qy-SfOk:zip:dataset_tsmc2014/dataset_TSMC2014_TKY.txt', 'TKY', 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
+        users = {}
+        venues = {}
+        edges = []
+        with open_upstream_file(name, fname, "rb") as bf:
+            f = io.TextIOWrapper(bf, encoding="latin-1")
+            for line in f:
+                uid, vid, cid, cname, lat, lon, tz, t = line.rstrip("\r\n").split("\t")
+                if uid not in users:
+                    users[uid] = len(users)
+                if vid not in venues:
+                    venues[vid] = (len(venues), cid, cname)
+                t = _utc_time(t)
+                edges.append((users[uid], venues[vid][0], int(t), int(tz),
+                              float(lat), float(lon)))
+        NU = len(users)
+        g = Graph(directed=False)
+        g.add_vertex(NU + len(venues))
+        g.vp.is_user = g.new_vp("bool")
+        g.vp.is_user.a[:NU] = True
+        g.vp.name = g.new_vp("string")
+        g.vp.category = g.new_vp("string")
+        g.vp.category_id = g.new_vp("string")
+        for uid, u in users.items():
+            g.vp.name[u] = uid
+        for vid, (v, cid, cname) in venues.items():
+            g.vp.name[NU + v] = vid
+            g.vp.category[NU + v] = cname
+            g.vp.category_id[NU + v] = cid
+        g.ep.time = g.new_ep("int64_t")
+        g.ep.tz_offset = g.new_ep("int")
+        g.ep.latitude = g.new_ep("double")
+        g.ep.longitude = g.new_ep("double")
+        edges = numpy.array(edges, dtype="float")
+        edges[:, 1] += NU
+        g.add_edge_list(edges, eprops=[g.ep.time, g.ep.tz_offset,
+                                       g.ep.latitude, g.ep.longitude])
+        yield alt, g