Arc प्लॉट
अब आगे, नेटवर्क को विज़ुअलाइज़ करने के लिए Arc प्लॉट का उपयोग करें. आप ग्राफ़ में nodes को sort करने का अभ्यास भी करेंगे.
नोट: यदि आपने सही किया, तो इस अभ्यास को चलने में लगभग 4–7 सेकंड लग सकते हैं.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में नेटवर्क विश्लेषण का परिचय
अभ्यास निर्देश
- GitHub collaboration नेटवर्क का Arc प्लॉट बनाएँ, जिसमें authors को degree के आधार पर sort किया गया हो. ऐसा करने के लिए:
Gके सभी nodes पर, उनके मेटाडेटा सहित, iterate करें (इसके लिएdata=Trueदें).- लूप की हर iteration में,
nx.degree()से प्रत्येक nodenकी degree निकालें और उसका'degree'attribute सेट करें.nx.degree()दो arguments लेता है: एक ग्राफ़ और एक node. - nodes को sort कराने के लिए दो parameters देकर
arcप्लॉटaबनाएँ:graphargument के रूप मेंGऔरsort_byargument के रूप में'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()