クリークを見つける(II)
すばらしいです!次は、特定の極大クリークを見つけて、そのクリークをプロットしてみましょう。
この演習はコースの一部です
Pythonで学ぶネットワーク分析入門
演習の手順
- 最大極大クリークに属する著者(複数の場合もあります)を見つけ、そのクリーク(の一つ)の部分グラフを Circos プロットで描画します。手順は次のとおりです。
nx.find_cliques()関数を使ってGの極大クリークを求めます。これを用意されたsorted()関数の中に入れて、最大の極大クリークを計算します。.subgraph()メソッドにlargest_cliqueを渡して、最大極大クリークからなる部分グラフを作成します。- サブグラフ
G_lc(他の引数なし)を使ってCircos plotオブジェクトを作成し、プロットします。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Import necessary modules
import networkx as nx
from nxviz import circos
import matplotlib.pyplot as plt
# Find the author(s) that are part of the largest maximal clique: largest_clique
largest_clique = sorted(____, key=lambda x:len(x))[-1]
# Create the subgraph of the largest_clique: G_lc
G_lc = ____
# Create the Circos plot: c
c = ____
# Draw the Circos plot to the screen
____
plt.show()