開始使用免費開始

使用 nxviz 視覺化篩選後的圖形

這裡你會用 circos 視覺化來呈現篩選後的圖形。circos 對此情境相當合適,因為你可以用節點分組與著色來呈現分割,而圓形的佈局也能維持視覺化的美感。

本練習屬於課程

Python 網路分析進階

檢視課程

練習說明

  • 使用二部圖模組的度中心性來計算每個節點的度中心性分數,但以原始圖形中的度中心性為基礎。
    • 為此請使用 nx.bipartite.degree_centrality() 函式,並傳入參數 Gnodes=forum_nodes
  • 建立新的 circos 視覺化,將節點依其分割標籤('bipartite')進行著色與分組(參數 node_color_bygroup_by),並依其度中心性('dc')排序(參數 sort_by),接著顯示出來。
    • 為了確保節點在顯示時清楚可見,我們已包含引數 node_enc_kwargs={'radius': 10}

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Import necessary modules
from nxviz import circos
import networkx as nx
import matplotlib.pyplot as plt

# Compute degree centrality scores of each node
dcs = ____(____, nodes=____)
for n, d in G_sub.nodes(data=True):
    G_sub.nodes[n]['dc'] = dcs[n]

# Create the circos plot: c
c = _____(___, _____, _____, _____, node_enc_kwargs={'radius': 5})

# Display the plot
plt.show() 
編輯並執行程式碼