Datasets
This tutorial shows how to load graphs from existing datasets, NetSet and Konect.
[1]:
from sknetwork.data import load_netset, load_konect
NetSet
Loading a graph from the NetSet collection.
[2]:
graph = load_netset('openflights')
adjacency = graph.adjacency
names = graph.names
Downloading openflights from NetSet...
Unpacking archive...
Parsing files...
Done.
[3]:
# to get all fields
graph
[3]:
{'meta': {'name': 'openflights',
'description': 'Airports with daily number of flights between them.',
'source': 'https://openflights.org'},
'adjacency': <3097x3097 sparse matrix of type '<class 'numpy.int64'>'
with 36386 stored elements in Compressed Sparse Row format>,
'names': array(['Goroka Airport', 'Madang Airport', 'Mount Hagen Kagamuga Airport',
..., 'Saumlaki/Olilit Airport', 'Tarko-Sale Airport',
'Alashankou Bole (Bortala) airport'], dtype='<U65'),
'position': array([[145.39199829, -6.08168983],
[145.78900147, -5.20707989],
[144.29600525, -5.82678986],
...,
[131.30599976, -7.98860979],
[ 77.81809998, 64.93080139],
[ 82.3 , 44.895 ]])}
[4]:
# Directed graph
graph = load_netset('wikivitals')
adjacency = graph.adjacency
names = graph.names
labels = graph.labels
Downloading wikivitals from NetSet...
Unpacking archive...
Parsing files...
Done.
[5]:
# Bipartite graph
graph = load_netset('cinema')
biadjacency = graph.biadjacency
Downloading cinema from NetSet...
Unpacking archive...
Parsing files...
Done.
Konect
Loading a graph from the Konect collection.
[6]:
graph = load_konect('dolphins')
adjacency = graph.adjacency
Downloading dolphins from Konect...
Unpacking archive...
Parsing files...
[7]:
graph
[7]:
{'names': array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62]),
'adjacency': <62x62 sparse matrix of type '<class 'numpy.int64'>'
with 318 stored elements in Compressed Sparse Row format>,
'meta': {'name': ' Dolphins',
'code': ' DO',
'url': ' http://www-personal.umich.edu/~mejn/netdata/',
'category': ' Animal',
'description': ' Dolphin–dolphin associations',
'cite': ' konect:dolphins',
'long-description': ' This is a directed social network of bottlenose dolphins. The nodes are the bottlenose dolphins (genus <i>Tursiops</i>) of a bottlenose dolphin community living off Doubtful Sound, a fjord in New Zealand (spelled <i>fiord</i> in New Zealand). An edge indicates a frequent association. The dolphins were observed between 1994 and 2001. ',
'entity-names': ' dolphin',
'relationship-names': ' association',
'extr': ' dolphins',
'timeiso': ' 1994/2001'}}