शुरू करेंमुफ़्त में शुरू करें

Matrix plot

चलिए अब कुछ visualizations बनाकर अभ्यास करते हैं। पहला होगा Matrix plot. किसी Matrix plot में, मैट्रिक्स edges का निरूपण होता है।

यह अभ्यास पाठ्यक्रम का हिस्सा है

Python में नेटवर्क विश्लेषण का परिचय

पाठ्यक्रम देखें

अभ्यास निर्देश

  • सबसे बड़े connected component उप-ग्राफ़ का Matrix plot visualization बनाइए, जहाँ authors को उनके user group नंबर के अनुसार group किया गया हो।
    • पहले, दिए गए sorted() फंक्शन के अंदर nx.connected_components(G) का उपयोग करके सबसे बड़ा connected component उप-ग्राफ़ निकालें। Python का बिल्ट-इन sorted() फंक्शन किसी iterable को लेता है और एक sorted लिस्ट लौटाता है (डिफ़ॉल्ट रूप से ascending क्रम में)। इसलिए, सबसे बड़े connected component उप-ग्राफ़ तक पहुँचने के लिए स्टेटमेंट को [-1] से slice किया गया है।
    • matrix plot h बनाइए। आपको graph और group_by पैरामीटर्स को क्रमशः सबसे बड़े connected component उप-ग्राफ़ और 'grouping' के रूप में निर्दिष्ट करना है।
    • matrix plot को स्क्रीन पर ड्रॉ कीजिए।

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Import necessary modules
from nxviz import matrix
import matplotlib.pyplot as plt

# Calculate the largest connected component: largest_ccs
largest_ccs = sorted(____, key=lambda x: len(x))[-1]

# Create the customized Matrix plot: h
h = ____

# Draw the Matrix plot to the screen
plt.show()
कोड संपादित करें और चलाएँ