Commit 2f8cde8f authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

escorts: extract from upstream instead of konect

parent 3f2933bb
......@@ -17,16 +17,17 @@
# along with this program. If not, see <>.
from .. import *
import csv
title = "Brazilian prostitution network (2010)"
description = """A bipartite network of escort and individuals who buy sex from them in Brazil, extracted from a Brazilian online community for such ratings. Edges represent a purchase of sexual intercourse with an escort, and the edge weight gives the buyer's rating of the escort: -1 (bad), 0 (neutral), or +1 (good). Other edge attributes are available. Edges are timestamped.[^icon]
[^icon]: Description obtained from the [ICON]( project."""
tags = ['Social', 'Public Health', 'Weighted', 'Timestamps']
url = ''
url = ''
citation = [('L. Rocha, F. Liljeros, & P. Holme. "Simulated epidemics in an empirical spatiotemporal network of 50,185 sexual contacts." PLoS Comput Biol, 7(3). (2011).', '')]
icon_hash = '5832214b8cf714f319c427a0'
upstream_prefix = ''
files = [('download.tsv.escorts.tar.bz2', None, 'konect')]
upstream_prefix = ''
files = [('journal.pcbi.1001109.s001', None, 'csv')]
def fetch_upstream(force=False):
return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
......@@ -44,6 +45,20 @@ def parse(alts=None):
if isinstance(fnames, str):
fnames = [fnames]
with ExitStack() as stack:
fs = [stack.enter_context(open_upstream_file(name, fn, "rb")) for fn in fnames]
g = parse_graph(fs, fmt, directed=True)
fs = [stack.enter_context(open_upstream_file(name, fn, "r")) for fn in fnames]
g = Graph(directed=True)
reader = csv.reader(fs[0], delimiter=";")
def edges():
for row in reader:
if len(row) == 1:
yield [int(x) for x in row]
eprops = ["time", "rating", "anal", "oral", "kiss"]
for p in eprops:
g.ep[p] = g.new_ep("int")
g.add_edge_list(edges(), hashed=False,
eprops=[g.ep[p] for p in eprops])
g.vp.male = g.new_vp("bool")
g.vp.male.a = g.degree_property_map("out").a > 0
yield alt, g
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment