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

Arc प्लॉट

अब आगे, नेटवर्क को विज़ुअलाइज़ करने के लिए Arc प्लॉट का उपयोग करें. आप ग्राफ़ में nodes को sort करने का अभ्यास भी करेंगे.

नोट: यदि आपने सही किया, तो इस अभ्यास को चलने में लगभग 4–7 सेकंड लग सकते हैं.

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

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

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

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

  • GitHub collaboration नेटवर्क का Arc प्लॉट बनाएँ, जिसमें authors को degree के आधार पर sort किया गया हो. ऐसा करने के लिए:
    • G के सभी nodes पर, उनके मेटाडेटा सहित, iterate करें (इसके लिए data=True दें).
    • लूप की हर iteration में, nx.degree() से प्रत्येक node n की degree निकालें और उसका 'degree' attribute सेट करें. nx.degree() दो arguments लेता है: एक ग्राफ़ और एक node.
    • nodes को sort कराने के लिए दो parameters देकर arc प्लॉट a बनाएँ: graph argument के रूप में G और sort_by argument के रूप में 'degree'.
    • स्क्रीन पर arc प्लॉट दिखाएँ.

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

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

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

# Iterate over all the nodes in G, including the metadata
for n, d in ____:

    # Calculate the degree of each node: G.node[n]['degree']
    ____ = ____

# Create the Arc plot: a
a = ____

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