History of mislove_osn
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] Add the date when each entry was added, and remove icon_hash 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/mislove_osn/__init__.py b/entries/mislove_osn/__init__.py
index 3a9d9ca..1ccaa45 100644
--- a/entries/mislove_osn/__init__.py
+++ b/entries/mislove_osn/__init__.py
@@ -44,7 +44,7 @@ The networks have the following properties:
tags = ['Social', 'Online', 'Unweighted', 'Affiliation', 'Metadata']
url = 'http://socialnetworks.mpi-sws.org/data-imc2007.html'
citation = [('A. Mislove et al., "Measurement and Analysis of Online Social Networks." Proc. ACM/Usenix Internet Measurement Conference (IMC), 29-42 (2007).', 'https://doi.org/10.1145/1298306.1298311')]
-icon_hash = ['56a85c8e26855e083a2f793c', '573429c5461efe0c7a678311']
+date_added = '2020-08-11'
upstream_license = None
# Too large to process on an ordinary machine (see --skip-huge)
huge = True
[entries] Prefix the properties in the descriptions with (Node), (Edge) or (Graph) 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/mislove_osn/__init__.py b/entries/mislove_osn/__init__.py
index 9c9070c..3a9d9ca 100644
--- a/entries/mislove_osn/__init__.py
+++ b/entries/mislove_osn/__init__.py
@@ -38,9 +38,9 @@ Undirected versions of the `orkut` and `youtube` networks (the largest connected
The networks have the following properties:
-- `vid`: the anonymized user ID (or, in the membership networks, the anonymized user or group ID).
-- `groups` (social networks): the list of IDs of the groups of which the user is a member (empty if the user is not a member of any group).
-- `is_group` (membership networks): true for groups, false for users."""
+- (Node) `vid`: the anonymized user ID (or, in the membership networks, the anonymized user or group ID).
+- (Node) `groups` (social networks): the list of IDs of the groups of which the user is a member (empty if the user is not a member of any group).
+- (Node) `is_group` (membership networks): true for groups, false for users."""
tags = ['Social', 'Online', 'Unweighted', 'Affiliation', 'Metadata']
url = 'http://socialnetworks.mpi-sws.org/data-imc2007.html'
citation = [('A. Mislove et al., "Measurement and Analysis of Online Social Networks." Proc. ACM/Usenix Internet Measurement Conference (IMC), 29-42 (2007).', 'https://doi.org/10.1145/1298306.1298311')]
[entries] Remove unneeded code from the entries 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/mislove_osn/__init__.py b/entries/mislove_osn/__init__.py
index 1b6dd77..9c9070c 100644
--- a/entries/mislove_osn/__init__.py
+++ b/entries/mislove_osn/__init__.py
@@ -64,7 +64,6 @@ def fetch_upstream(force=False):
#@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:
@@ -95,7 +94,6 @@ def parse(alts=None):
dtype=numpy.int64).values
g.vp.vid = g.add_edge_list(edges, hashed=True)
del edges
- vid = g.vp.vid
g.vp.groups = groups = g.new_vp("vector<int32_t>")
# group memberships (user ID, group ID), possibly several per user
[entries] Merge duplicate entries and add cross-references between related ones 9bc6033
- Removed duplicates, merged into the entries holding the same data: dblp_coauthor_snap (soc_net_comms), cattle and bison (dom; bison's breeding data move there, as do the wolves' age and sex), football_tsevans (football, with both conference assignments), eu_procurements_alt (eu_procurements), foursquare_friendships (foursquare_global). - software_dependencies: colt and scolt are one network; ambassador: the duplicate 2001 network is dropped and the three same-edge networks combined; dom: the dataset count corrected (436). - macaque_neural: Young's 71-area network added (young71; the 47-area one is now cocomac47), both from archived copies. - collins_yeast, celegans_interactomes: from archived copies of the dead CCSB site (byte-identical files). - Cross-references between entries holding versions of the same data (food webs, Wikipedia, Slashdot, physicians, SNAP/Mislove, CCSB). - ICON ids of duplicate records added; macaque_neural's corrected. - prosper, dbpedia_all: string properties given in edge-index order (needs graph-tool with the fixed vals ordering).
diff --git a/entries/mislove_osn/__init__.py b/entries/mislove_osn/__init__.py
index ccea1d8..1b6dd77 100644
--- a/entries/mislove_osn/__init__.py
+++ b/entries/mislove_osn/__init__.py
@@ -34,6 +34,8 @@ The data also include the memberships of users in user groups (special interest
(The membership networks of LiveJournal and Orkut, with about 112 and 327 million memberships, are only available as node properties.)
+Undirected versions of the `orkut` and `youtube` networks (the largest connected component, in the case of YouTube), with communities derived from the group memberships, are the networks `orkut` and `youtube` of the entry `soc_net_comms`.
+
The networks have the following properties:
- `vid`: the anonymized user ID (or, in the membership networks, the anonymized user or group ID).
[entries] Fix parse bugs and improve descriptions and metadata 6bb6851
- parse fixes from the review of the descriptions, e.g. us_patents (directed), celegans_2019 (synapse direction), ecoli_transcription and yeast_transcription (regulator to target), bitcoin (direction, phantom node), ego_social (Google+ features and circles), scotus_majority, arxiv_authors and social_location (as in SNAP), caida_as, dnc, dom, mist, reuters and bibsonomy (names on the right nodes), uci_zoo - every description now states explicitly what the nodes and edges represent; corrected titles, years, tags, citations and licences - the "Hypergraph" tag is removed; very large entries are marked `huge = True` (see --skip-huge) - ICON ids of partial duplicates added (hiv_transmission, congress_bills, openflights, dutch_school)
diff --git a/entries/mislove_osn/__init__.py b/entries/mislove_osn/__init__.py
index 1569abd..ccea1d8 100644
--- a/entries/mislove_osn/__init__.py
+++ b/entries/mislove_osn/__init__.py
@@ -44,6 +44,8 @@ url = 'http://socialnetworks.mpi-sws.org/data-imc2007.html'
citation = [('A. Mislove et al., "Measurement and Analysis of Online Social Networks." Proc. ACM/Usenix Internet Measurement Conference (IMC), 29-42 (2007).', 'https://doi.org/10.1145/1298306.1298311')]
icon_hash = ['56a85c8e26855e083a2f793c', '573429c5461efe0c7a678311']
upstream_license = None
+# Too large to process on an ordinary machine (see --skip-huge)
+huge = True
upstream_prefix = 'http://socialnetworks.mpi-sws.mpg.de/data'
files = [(('flickr-links.txt.gz', 'flickr-groupmemberships.txt.gz'), 'flickr', None),
(('livejournal-links.txt.gz', 'livejournal-groupmemberships.txt.gz'), 'livejournal', None),
[entries] Merge the KONECT duplicates jdk, jung and flickr_groups into existing entries 31e053f
jdk and jung are the jdk and jung-j networks of software_dependencies, and flickr_groups the Flickr group memberships of mislove_osn. Their ICON ids, citations and descriptions were merged into those entries, which also gain the class names from the upstream .map files (software_dependencies) and the Flickr and YouTube user-group memberships as bipartite networks (mislove_osn).
diff --git a/entries/mislove_osn/__init__.py b/entries/mislove_osn/__init__.py
index 62cea7e..1569abd 100644
--- a/entries/mislove_osn/__init__.py
+++ b/entries/mislove_osn/__init__.py
@@ -17,20 +17,40 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
from .. import *
+import pandas
title = "Mislove et al. OSNs (2006-2007)"
-description = """Network structure for four large online social networks: Flickr (2007), LiveJournal (2006), Orkut (2006), and YouTube (2007). Edges are given as directed, even in Orkut. Each network includes a list of user groups and their users[^icon]
-[^icon]: Description obtained from the [ICON](https://icon.colorado.edu) project."""
-tags = ['Social', 'Online', 'Unweighted']
+description = """Social graphs of four large online social networks, obtained by A. Mislove and collaborators by crawling the publicly accessible user links of each site with automated scripts. Nodes are users and a directed edge $(i,j)$ indicates that user $i$ lists user $j$ as a friend or contact. The four networks are:
+
+- `flickr`: the photo sharing site Flickr, crawled on 9 January 2007 through its API, by following forward links from seed users. It covers an estimated 26.9% of all users; 62.0% of the links are reciprocated.
+- `livejournal`: the blogging site LiveJournal, crawled on 9–11 December 2006 through its API by following both forward and reverse links, which covers the entire large weakly connected component, an estimated 95.4% of all users; 73.5% of the links are reciprocated.
+- `orkut`: the social networking site Orkut run by Google, crawled between 3 October and 11 November 2006 by HTML screen-scraping. The crawl was stopped after reaching 3,072,441 users, an estimated 11.3% of all users, and links to uncrawled users are disregarded. Orkut friendships are undirected and require the consent of both users, but they are given as directed, so each friendship appears as two reciprocal edges.
+- `youtube`: the video sharing site YouTube, crawled on 15 January 2007 through its API, by following forward links. The fraction of users covered is unknown; 79.1% of the links are reciprocated.
+
+The data also include the memberships of users in user groups (special interest groups created by users; in LiveJournal they were inferred from the interests specified by users). The user IDs and group IDs were anonymized. In the four social networks above, the memberships are given as a node property, and the memberships of users absent from the social graph (e.g. 11,872 Flickr users with 33,901 memberships) are not included. They are included in the bipartite user-group membership networks of the two smaller sites:
+
+- `flickr_groups`: memberships of Flickr users in Flickr groups.
+- `youtube_groups`: memberships of YouTube users in YouTube groups.
+
+(The membership networks of LiveJournal and Orkut, with about 112 and 327 million memberships, are only available as node properties.)
+
+The networks have the following properties:
+
+- `vid`: the anonymized user ID (or, in the membership networks, the anonymized user or group ID).
+- `groups` (social networks): the list of IDs of the groups of which the user is a member (empty if the user is not a member of any group).
+- `is_group` (membership networks): true for groups, false for users."""
+tags = ['Social', 'Online', 'Unweighted', 'Affiliation', 'Metadata']
url = 'http://socialnetworks.mpi-sws.org/data-imc2007.html'
citation = [('A. Mislove et al., "Measurement and Analysis of Online Social Networks." Proc. ACM/Usenix Internet Measurement Conference (IMC), 29-42 (2007).', 'https://doi.org/10.1145/1298306.1298311')]
-icon_hash = '56a85c8e26855e083a2f793c'
-ustream_license = None
+icon_hash = ['56a85c8e26855e083a2f793c', '573429c5461efe0c7a678311']
+upstream_license = None
upstream_prefix = 'http://socialnetworks.mpi-sws.mpg.de/data'
files = [(('flickr-links.txt.gz', 'flickr-groupmemberships.txt.gz'), 'flickr', None),
(('livejournal-links.txt.gz', 'livejournal-groupmemberships.txt.gz'), 'livejournal', None),
(('orkut-links.txt.gz', 'orkut-groupmemberships.txt.gz'), 'orkut', None),
- (('youtube-links.txt.gz', 'youtube-groupmemberships.txt.gz'), 'youtube', None)]
+ (('youtube-links.txt.gz', 'youtube-groupmemberships.txt.gz'), 'youtube', None),
+ (('flickr-groupmemberships.txt.gz',), 'flickr_groups', 'groups'),
+ (('youtube-groupmemberships.txt.gz',), 'youtube_groups', 'groups')]
def fetch_upstream(force=False):
return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
@@ -49,23 +69,50 @@ def parse(alts=None):
fnames = [fnames]
with ExitStack() as stack:
fs = [stack.enter_context(open_upstream_file(name, fn, "r")) for fn in fnames]
+ if fmt == "groups":
+ # bipartite user-group membership network
+ m = pandas.read_csv(fs[0], sep="\t", header=None, comment="#",
+ dtype=numpy.int64).values
+ users, ui = numpy.unique(m[:, 0], return_inverse=True)
+ grps, gi = numpy.unique(m[:, 1], return_inverse=True)
+ g = Graph(directed=False)
+ g.add_vertex(len(users) + len(grps))
+ g.add_edge_list(numpy.column_stack((ui.ravel(),
+ len(users) + gi.ravel())))
+ g.vp.vid = g.new_vp("int64_t",
+ vals=numpy.concatenate((users, grps)))
+ g.vp.is_group = g.new_vp("bool")
+ g.vp.is_group.a[len(users):] = True
+ del m, ui, gi
+ yield alt, g
+ continue
g = Graph()
- def get_edges():
- for line in fs[0]:
- yield line.split()
- g.vp.vid = g.add_edge_list(get_edges(), hashed=True,
- hash_type="int")
+ edges = pandas.read_csv(fs[0], sep="\t", header=None, comment="#",
+ dtype=numpy.int64).values
+ g.vp.vid = g.add_edge_list(edges, hashed=True)
+ del edges
vid = g.vp.vid
- g.vp.group = group = g.new_vp("int")
+ g.vp.groups = groups = g.new_vp("vector<int32_t>")
- groups = {}
- for line in fs[1]:
- vals = line.split()
- groups[int(vals[0])] = int(vals[1])
- for v in g.vertices():
- try:
- group[v] = groups[vid[v]]
- except KeyError:
- group[v] = -1
- print("no group for vertex", int(v))
+ # group memberships (user ID, group ID), possibly several per user
+ m = pandas.read_csv(fs[1], sep="\t", header=None, comment="#",
+ dtype=numpy.int64).values
+ vids = g.vp.vid.fa
+ idx = numpy.argsort(vids)
+ pos = numpy.searchsorted(vids, m[:, 0], sorter=idx)
+ pos[pos == len(vids)] = 0
+ found = vids[idx[pos]] == m[:, 0]
+ if (~found).sum() > 0:
+ print("memberships of users not in the graph:", (~found).sum())
+ us = idx[pos[found]]
+ gs = m[found, 1]
+ del m, pos, found
+ order = numpy.argsort(us, kind="stable")
+ us = us[order]
+ gs = gs[order]
+ del order
+ bounds = numpy.searchsorted(us, numpy.arange(g.num_vertices() + 1))
+ for v in range(g.num_vertices()):
+ if bounds[v + 1] > bounds[v]:
+ groups[v] = gs[bounds[v]:bounds[v + 1]]
yield alt, g
Update copyright information 73a4f0d
diff --git a/entries/mislove_osn/__init__.py b/entries/mislove_osn/__init__.py
index b201be2..62cea7e 100644
--- a/entries/mislove_osn/__init__.py
+++ b/entries/mislove_osn/__init__.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2020-2024 Tiago de Paula Peixoto <tiago@skewed.de>
+# 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
Update copyright information 3d288ea
diff --git a/entries/mislove_osn/__init__.py b/entries/mislove_osn/__init__.py
index 91b3d39..b201be2 100644
--- a/entries/mislove_osn/__init__.py
+++ b/entries/mislove_osn/__init__.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2020-2023 Tiago de Paula Peixoto <tiago@skewed.de>
+# Copyright (C) 2020-2024 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
Update copyright information 8d005ae
diff --git a/entries/mislove_osn/__init__.py b/entries/mislove_osn/__init__.py
index 93772e7..91b3d39 100644
--- a/entries/mislove_osn/__init__.py
+++ b/entries/mislove_osn/__init__.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2021 Tiago de Paula Peixoto <tiago@skewed.de>
+# Copyright (C) 2020-2023 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
Update copyright info db2efcc
diff --git a/entries/mislove_osn/__init__.py b/entries/mislove_osn/__init__.py
index 347c236..93772e7 100644
--- a/entries/mislove_osn/__init__.py
+++ b/entries/mislove_osn/__init__.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2020 Tiago de Paula Peixoto <tiago@skewed.de>
+# Copyright (C) 2021 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
Update citations to use DOIs e878874
diff --git a/entries/mislove_osn/__init__.py b/entries/mislove_osn/__init__.py
index 5f4d5af..347c236 100644
--- a/entries/mislove_osn/__init__.py
+++ b/entries/mislove_osn/__init__.py
@@ -23,7 +23,7 @@ description = """Network structure for four large online social networks: Flickr
[^icon]: Description obtained from the [ICON](https://icon.colorado.edu) project."""
tags = ['Social', 'Online', 'Unweighted']
url = 'http://socialnetworks.mpi-sws.org/data-imc2007.html'
-citation = [('A. Mislove et al., "Measurement and Analysis of Online Social Networks." Proc. ACM/Usenix Internet Measurement Conference (IMC), 29-42 (2007).', 'http://conferences.sigcomm.org/imc/2007/papers/imc170.pdf')]
+citation = [('A. Mislove et al., "Measurement and Analysis of Online Social Networks." Proc. ACM/Usenix Internet Measurement Conference (IMC), 29-42 (2007).', 'https://doi.org/10.1145/1298306.1298311')]
icon_hash = '56a85c8e26855e083a2f793c'
ustream_license = None
upstream_prefix = 'http://socialnetworks.mpi-sws.mpg.de/data'
Change license from GPLv3 to AGPLv3 d754be5
diff --git a/entries/mislove_osn/__init__.py b/entries/mislove_osn/__init__.py
index a36a8ce..5f4d5af 100644
--- a/entries/mislove_osn/__init__.py
+++ b/entries/mislove_osn/__init__.py
@@ -3,18 +3,18 @@
#
# Copyright (C) 2020 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 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 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 General Public License for more details.
+# 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 General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# 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 *
Add explicit attribution to descriptions obtained from ICON 1645314
diff --git a/entries/mislove_osn/__init__.py b/entries/mislove_osn/__init__.py
index 9458d9c..a36a8ce 100644
--- a/entries/mislove_osn/__init__.py
+++ b/entries/mislove_osn/__init__.py
@@ -19,7 +19,8 @@
from .. import *
title = "Mislove et al. OSNs (2006-2007)"
-description = "Network structure for four large online social networks: Flickr (2007), LiveJournal (2006), Orkut (2006), and YouTube (2007). Edges are given as directed, even in Orkut. Each network includes a list of user groups and their users"
+description = """Network structure for four large online social networks: Flickr (2007), LiveJournal (2006), Orkut (2006), and YouTube (2007). Edges are given as directed, even in Orkut. Each network includes a list of user groups and their users[^icon]
+[^icon]: Description obtained from the [ICON](https://icon.colorado.edu) project."""
tags = ['Social', 'Online', 'Unweighted']
url = 'http://socialnetworks.mpi-sws.org/data-imc2007.html'
citation = [('A. Mislove et al., "Measurement and Analysis of Online Social Networks." Proc. ACM/Usenix Internet Measurement Conference (IMC), 29-42 (2007).', 'http://conferences.sigcomm.org/imc/2007/papers/imc170.pdf')]
Initial commit cc85872
diff --git a/entries/mislove_osn/__init__.py b/entries/mislove_osn/__init__.py
new file mode 100644
index 0000000..9458d9c
--- /dev/null
+++ b/entries/mislove_osn/__init__.py
@@ -0,0 +1,70 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2020 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 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from .. import *
+
+title = "Mislove et al. OSNs (2006-2007)"
+description = "Network structure for four large online social networks: Flickr (2007), LiveJournal (2006), Orkut (2006), and YouTube (2007). Edges are given as directed, even in Orkut. Each network includes a list of user groups and their users"
+tags = ['Social', 'Online', 'Unweighted']
+url = 'http://socialnetworks.mpi-sws.org/data-imc2007.html'
+citation = [('A. Mislove et al., "Measurement and Analysis of Online Social Networks." Proc. ACM/Usenix Internet Measurement Conference (IMC), 29-42 (2007).', 'http://conferences.sigcomm.org/imc/2007/papers/imc170.pdf')]
+icon_hash = '56a85c8e26855e083a2f793c'
+ustream_license = None
+upstream_prefix = 'http://socialnetworks.mpi-sws.mpg.de/data'
+files = [(('flickr-links.txt.gz', 'flickr-groupmemberships.txt.gz'), 'flickr', None),
+ (('livejournal-links.txt.gz', 'livejournal-groupmemberships.txt.gz'), 'livejournal', None),
+ (('orkut-links.txt.gz', 'orkut-groupmemberships.txt.gz'), 'orkut', None),
+ (('youtube-links.txt.gz', 'youtube-groupmemberships.txt.gz'), 'youtube', 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 fnames, alt, fmt in files:
+ if alts is not None and alt not in alts:
+ continue
+ if isinstance(fnames, str):
+ fnames = [fnames]
+ with ExitStack() as stack:
+ fs = [stack.enter_context(open_upstream_file(name, fn, "r")) for fn in fnames]
+ g = Graph()
+ def get_edges():
+ for line in fs[0]:
+ yield line.split()
+ g.vp.vid = g.add_edge_list(get_edges(), hashed=True,
+ hash_type="int")
+ vid = g.vp.vid
+ g.vp.group = group = g.new_vp("int")
+
+ groups = {}
+ for line in fs[1]:
+ vals = line.split()
+ groups[int(vals[0])] = int(vals[1])
+ for v in g.vertices():
+ try:
+ group[v] = groups[vid[v]]
+ except KeyError:
+ group[v] = -1
+ print("no group for vertex", int(v))
+ yield alt, g