This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 『オープンソースで学ぶ社会ネットワーク分析』の図1-4のネットワーク図を描く | |
import networkx as net | |
import matplotlib.pyplot as plot | |
# pylabの全ての関数やオブジェクトをインポート(本に書かれてないコード) | |
from pylab import * | |
# "ACME_orgchart.net"はpythonを実行しているフォルダー内に置く | |
# "ACME_orgchart.net"は以下のGitHubよりDLできる |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NetworkXをインストール | |
easy_install networkx | |
# NumPyをインストール | |
easy_install numpy | |
# matplotlibをインストール | |
easy_install matplotlib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pythonでヒストグラム | |
# [データ]https://github.com/maksim2042/SNABook/tree/master/chapter1/egypt_retweets.net | |
# データファイルはpythonを実行しているフォルダーと同じ階層に置く | |
e=net.read_pajek("egypt_retweets.net") | |
len(e) # 25178 | |
len(net.connected_component_subgraphs(e)) # 3122 | |
import matplotlib.pyplot as plot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# オープンソースで学ぶ社会ネットワーク分析 | |
# 第6章 バイラルへ!- 情報の拡散 | |
# 拡散モデルのエージェントのネットワーク(図6-5) | |
import networkx as net | |
import matplotlib.pyplot as plot | |
import matplotlib.colors as colors | |
import random as r | |
class Person(object): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# オープンソースで学ぶ社会ネットワーク分析 | |
# 第6章 バイラルへ!- 情報の拡散 | |
# 拡散モデルのエージェントのネットワーク(図6-5) | |
import networkx as net | |
import matplotlib.pyplot as plot | |
import matplotlib.colors as colors | |
import random as r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Girvan Newman algorithmを使って空手クラブネットワークのコミュニティが分割していく様子を出力 | |
# Zachary's karate club(空手クラブのネットワーク)のデータ取得元URL | |
# http://www-personal.umich.edu/~mejn/netdata/ | |
import networkx as NX | |
import networkx.readwrite.gml as NRG | |
import networkx.algorithms.centrality as NC | |
import pylab as P |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Girvan Newman algorithmを使って空手クラブネットワークのコミュニティが分割していく様子を出力 | |
# Zachary's karate club(空手クラブのネットワーク)のデータ取得元URL | |
# http://www-personal.umich.edu/~mejn/netdata/ | |
import networkx as NX | |
import networkx.readwrite.gml as NRG | |
import networkx.algorithms.centrality as NC | |
import pylab as P |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# 集合知プログラミング第2章推薦を行う(前半) | |
# 映画の評者といくつかの映画に対する彼らの評点のディクショナリ | |
critics = { | |
'Lisa Rose':{ | |
'Lady in the Water': 2.5, | |
'Snakes on a Plane': 3.5, | |
'Just My Luck': 3.0, | |
'Superman Returns': 3.5, |