logo Netzschleuder network catalog, repository, and centrifuge

History of rt_retweets

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: rt_retweets by Tiago de Paula Peixoto 4410bb2
diff --git a/entries/rt_retweets/__init__.py b/entries/rt_retweets/__init__.py
new file mode 100644
index 0000000..bffd101
--- /dev/null
+++ b/entries/rt_retweets/__init__.py
@@ -0,0 +1,91 @@
+#! /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 = "Twitter retweet networks from the Network Repository (2009-2012)"
+description = r"""Networks of retweets among Twitter users, distributed by the Network Data Repository (R. A. Rossi and N. K. Ahmed) in its collection of retweet networks. Nodes are Twitter users (anonymized as consecutive indices), and edges are retweets. The provenance of most of the networks is documented only briefly by the repository. There are 33 networks:
+
+- 29 networks of retweets of tweets with a given hashtag, collected from July to September 2012 by the Truthy project of Indiana University (`alwefaq`, `assad`, `bahrain`, `barackobama`, `damascus`, `dash`, `gmanews`, `gop`, `http`, `islam`, `israel`, `justinbieber`, `ksa`, `lebanon`, `libya`, `lolgop`, `mittromney`, `obama`, `occupy`, `occupywallstnyc`, `oman`, `onedirection`, `p2`, `qatif`, `saudi`, `tcot`, `tlot`, `uae`, `voteonedirection`, named by the hashtag). These are directed networks, in which each ordered pair of users appears at most once, with a timestamp; the meaning of the direction (who retweeted whom) is not documented. A few edges are self-loops, as given.
+- `retweet` and `retweet_crawl`: undirected retweet networks from the same collection, without timestamps (96 and 1.1 million users).
+- `pol`: retweets among users who tweeted about US politics in the six weeks before the 2010 US midterm elections, from the study of political polarization of M. D. Conover and collaborators. A directed multigraph: repeated retweets between the same users, at different times, are separate edges; the repository describes the network as undirected, and the meaning of the direction is not documented.
+- `twitter_copen`: an undirected network of retweets and mentions during the two weeks of the UN Climate Change Conference in Copenhagen (2009), from the study of N. K. Ahmed and collaborators on network sampling.
+
+The retweet network about the discovery of the Higgs boson of the same collection (`rt-higgs`) is the retweet network of the entry `twitter_higgs`, and is not included.
+
+The networks have the following properties:
+
+- Edge `time` (hashtag networks and `pol`): the time of the retweet, in Unix time."""
+tags = ['Social', 'Online', 'Unweighted', 'Multigraph', 'Timestamps']
+url = ['https://networkrepository.com/rt.php']
+citation = [('R. A. Rossi and N. K. Ahmed, "The Network Data Repository with Interactive Graph Analytics and Visualization." Proceedings of the AAAI Conference on Artificial Intelligence 29(1) (2015).', 'https://doi.org/10.1609/aaai.v29i1.9277'),
+            ('R. A. Rossi, D. F. Gleich, A. H. Gebremedhin, and M. M. A. Patwary, "Fast maximum clique algorithms for large graphs." Proceedings of the 23rd International Conference on World Wide Web (WWW Companion), 365-366 (2014).', 'https://doi.org/10.1145/2567948.2577283'),
+            ('M. D. Conover, J. Ratkiewicz, M. Francisco, B. Goncalves, F. Menczer, and A. Flammini, "Political Polarization on Twitter." Proceedings of the International AAAI Conference on Web and Social Media (ICWSM) 5, 89-96 (2011).', 'https://doi.org/10.1609/icwsm.v5i1.14126'),
+            ('N. K. Ahmed, F. Berchmans, J. Neville, and R. Kompella, "Time-based sampling of social network activity graphs." Proceedings of the Eighth Workshop on Mining and Learning with Graphs (MLG), 1-9 (2010).', 'https://doi.org/10.1145/1830252.1830253')]
+icon_hash = None
+upstream_license = ('CC BY-SA', 'https://networkrepository.com/policy.php')
+upstream_prefix = 'https://nrvis.com/download/data/rt'
+hashtags = ['alwefaq', 'assad', 'bahrain', 'barackobama', 'damascus', 'dash',
+            'gmanews', 'gop', 'http', 'islam', 'israel', 'justinbieber', 'ksa',
+            'lebanon', 'libya', 'lolgop', 'mittromney', 'obama', 'occupy',
+            'occupywallstnyc', 'oman', 'onedirection', 'p2', 'qatif', 'saudi',
+            'tcot', 'tlot', 'uae', 'voteonedirection']
+files = [(f'rt_{h}.zip:rt_{h}.edges', h, None) for h in hashtags]
+files += [('rt-retweet.zip:rt-retweet.mtx', 'retweet', None),
+          ('rt-retweet-crawl.zip:rt-retweet-crawl.mtx', 'retweet_crawl', None),
+          ('rt-pol.zip:rt-pol.txt', 'pol', None),
+          ('rt-twitter-copen.zip:rt-twitter-copen.mtx', 'twitter_copen', 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):
+    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, "r") as f:
+            if fname.endswith(".mtx"):
+                header = next(f)
+                assert header.startswith("%%MatrixMarket matrix coordinate pattern symmetric") or \
+                    header.startswith("%MatrixMarket matrix coordinate pattern symmetric")
+                lines = (l for l in f if not l.startswith("%"))
+                N, N2, M = map(int, next(lines).split())
+                E = numpy.array([l.split() for l in lines if l.strip()],
+                                dtype="int64")
+                assert N == N2 and len(E) == M and E.min() >= 1 and E.max() <= N
+                g = Graph(directed=False)
+                g.add_vertex(N)
+                g.add_edge_list(E - 1)
+            else:
+                E = numpy.array([l.strip().split(",") for l in f if l.strip()],
+                                dtype="int64")
+                # hashtag networks are numbered from 1, `pol` from 0
+                base = 0 if alt == "pol" else 1
+                assert E[:, :2].min() == base
+                g = Graph(directed=True)
+                g.add_vertex(E[:, :2].max() + 1 - base)
+                g.ep.time = g.new_ep("int64_t")
+                E[:, :2] -= base
+                g.add_edge_list(E, eprops=[g.ep.time])
+        yield alt, g