logo Netzschleuder network catalog, repository, and centrifuge

History of youtube_growth

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: youtube_growth by Tiago de Paula Peixoto b462f25
diff --git a/entries/youtube_growth/__init__.py b/entries/youtube_growth/__init__.py
new file mode 100644
index 0000000..486fb34
--- /dev/null
+++ b/entries/youtube_growth/__init__.py
@@ -0,0 +1,71 @@
+#! /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 = "YouTube friendship network growth (2006-2007)"
+description = """Growth of the network of friendships among users of the video sharing site YouTube, collected by A. Mislove and collaborators. The authors crawled the network once per day with automated scripts, following forward links from the users already discovered, between 10 December 2006 and 15 January 2007 and between 8 February and 23 July 2007 (201 days in total), and recorded the day on which each link was first observed. Since YouTube does not provide the creation times of the links, the times have a resolution of one day; links that existed when the crawl started have the date of the first crawl (10 December 2006), and links created between the two crawl periods have the date of the first crawl of the second period (8 February 2007). New users could only be discovered once they became connected to an already crawled user.
+
+Between the two crawl periods, YouTube started requiring the confirmation of friendship links by their destination, so that the network changed from directed to undirected. The authors therefore analyzed the two periods separately, as "YouTube-D" (until 15 January 2007) and "YouTube-U" (from 8 February 2007). The data contain the links of both periods as directed links; an undirected link appears as two links, one in each direction, which may have been observed on different days. Most links of the first period are also reciprocated (97%, against 99% in the second). The upstream file of YouTube-D is identical to the first part of the file of YouTube-U (up to 15 January 2007), and is therefore not included separately. The network contains 11,489 self-loops. The user IDs were anonymized.
+
+Nodes are users and a directed edge $(i,j)$ indicates that user $i$ added user $j$ as a friend.
+
+The network has the following properties:
+
+- `user_id`: the anonymized user ID in the source data.
+- `time`: the day on which the link was first observed, as the Unix time of 00:00 UTC of that day."""
+tags = ['Social', 'Online', 'Unweighted', 'Timestamps']
+url = 'http://socialnetworks.mpi-sws.org/data-wosn2008.html'
+citation = [('A. Mislove, "Online social networks: measurement, analysis, and applications to distributed information systems." PhD Thesis, Rice University (2009)', 'https://mislove.org/publications/SocialNetworks-Thesis.pdf')]
+icon_hash = None
+upstream_license = None
+upstream_prefix = 'https://socialnetworks.mpi-sws.org/data'
+files = [('youtube-u-growth.txt.gz', None, None)]
+TIME_FORMAT = "%Y-%m-%d"
+
+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):
+    import pandas
+    name = __name__.split(".")[-1]
+    for fnames, alt, fmt in files:
+        if alts is not None and alt not in alts:
+            continue
+        # Lines 'u v time', for a link from u to v observed at the given time
+        with open_upstream_file(name, fnames, "r") as f:
+            df = pandas.read_csv(f, sep="\t", header=None, names=["u", "v", "t"],
+                                 dtype={"u": numpy.int64, "v": numpy.int64,
+                                        "t": str})
+        t = pandas.to_datetime(df["t"], format=TIME_FORMAT).values
+        t = t.astype("datetime64[s]").astype(numpy.int64)
+        m = numpy.empty((len(df), 3), dtype=numpy.int64)
+        m[:, 0] = df["u"].values
+        m[:, 1] = df["v"].values
+        m[:, 2] = t
+        del df, t
+        g = Graph(directed=True)
+        g.ep.time = g.new_ep("int64_t")
+        g.vp.user_id = g.add_edge_list(m, hashed=True, eprops=[g.ep.time])
+        del m
+        yield alt, g