開始使用免費開始

尋找團(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()
編輯並執行程式碼