(2順目)
レシピ14.1
NetworkxはすでにAnacondにinstallすみ。 2項 adjリストの中身は
[(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (9, 0), (0, 2), (1, 3), (2, 4), (3, 5), (4, 6), (5, 7), (6,8), (7, 9), (8, 0), (9, 1)]
5項
6,7項
posの中身
print(pos)
[[ 1.00000000e+00 0.00000000e+00]
[ 7.66044443e-01 6.42787610e-01]
[ 1.73648178e-01 9.84807753e-01]
[ -5.00000000e-01 8.66025404e-01]
[ -9.39692621e-01 3.42020143e-01]
[ -9.39692621e-01 -3.42020143e-01]
[ -5.00000000e-01 -8.66025404e-01]
[ 1.73648178e-01 -9.84807753e-01]
[ 7.66044443e-01 -6.42787610e-01]
[ 1.00000000e+00 -2.44929360e-16]
[ 0.00000000e+00 0.00000000e+00]]
散布図で描画
plt.scatter(pos[:,0],pos[:,1])
8項
spectral_layoutアルゴリズムを使用しているとあるが詳細不明
応用
draw_springアルゴリズムでも描画
6,7項の図と変わらない。
レシピ14.2
Twitterのライブラリーはanacondには入っていなかったので
pip install twitterで入れた。
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\user-name>pip install twitter
Collecting twitter
Downloading twitter-1.17.1-py2.py3-none-any.whl (55kB)
100% |################################| 61kB 984kB/s
Installing collected packages: twitter
Successfully installed twitter-1.17.1
CONSUMER_KEY, CONSUMER_SECRET
OAUTH_TOKEN, OAUTH_TOKEN_SECRET
は以前取得したものを使った。
4~12項
このレシピは私のtwitterのフオロワーを表示するので
8項の"Python"に関係するもののみの条件を削除、上から10人の条件も削除
9項の孤立したノードを削除も条件から除外