4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

networkxのデータセット

Last updated at Posted at 2021-04-20

#はじめに

networkxとはpythonでグラフ・ネットワークを扱える便利なパッケージです。

開発環境
Python 3.8.3
networkx 2.4 

#データセット

##1. Zachary’s Karate Club graph
ノード数:34
エッジ数:78

論文:Zachary W. (1977). An information flow model for conflict and fission in small groups. Journal of Anthropological Research, 33, 452-473.

karate_club
import networkx as nx
G = nx.karate_club_graph()

##2.Davis Southern women social network.
ノード数:32
エッジ数:89

論文:Breiger R. (1974). The duality of persons and groups. Social Forces, 53, 181-190.

Davis_Southern_women_social_network
import networkx as nx
G = nx.davis_southern_women_graph()

##3.football
ノード数:115
エッジ数:613

論文:Girvan, Michelle, and Mark EJ Newman. "Community structure in social and biological networks." Proceedings of the national academy of sciences 99.12 (2002): 7821-7826.

football
import urllib.request as urllib
import io
import zipfile

import matplotlib.pyplot as plt
import networkx as nx

url = "http://www-personal.umich.edu/~mejn/netdata/football.zip"

sock = urllib.urlopen(url)  # open URL
s = io.BytesIO(sock.read())  # read into BytesIO "file"
sock.close()

zf = zipfile.ZipFile(s)  # zipfile object
txt = zf.read("football.txt").decode()  # read info file
gml = zf.read("football.gml").decode()  # read gml data
# throw away bogus first line with # from mejn files
gml = gml.split("\n")[1:]
G = nx.parse_gml(gml)  # parse gml data
4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?