การค้นหา Clique (II)
ทำได้ดีมาก! ต่อไปเราจะค้นหา maximal clique ที่ต้องการ แล้ววาดกราฟของ clique นั้นด้วย Circos plot
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การวิเคราะห์เครือข่ายเบื้องต้นด้วย Python
คำแนะนำการฝึกหัด
- ค้นหาผู้เขียนที่อยู่ใน maximal clique ที่ใหญ่ที่สุด แล้ววาด subgraph ของ clique นั้นด้วย Circos plot โดยทำตามขั้นตอนต่อไปนี้
- ใช้ฟังก์ชัน
nx.find_cliques()เพื่อคำนวณ maximal clique ทั้งหมดในGแล้วนำผลลัพธ์ไปใส่ภายในฟังก์ชันsorted()ที่เตรียมไว้ เพื่อหา maximal clique ที่ใหญ่ที่สุด - สร้าง subgraph จาก maximal clique ที่ใหญ่ที่สุด โดยใช้เมธอด
.subgraph()ร่วมกับlargest_clique - สร้างออบเจกต์
Circos plotโดยใช้ subgraphG_lc(โดยไม่ต้องระบุอาร์กิวเมนต์อื่น) แล้วแสดงผล
- ใช้ฟังก์ชัน
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# 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()