दिन-प्रतिदिन सबसे लोकप्रिय फ़ोरम खोजें: I
बहुत बढ़िया! आप अब आख़िरी दो अभ्यासों पर हैं — जो असल में एक लंबा अभ्यास ही है. ये आपके Python प्रोग्रामिंग स्किल्स के लिए एक अच्छा मेमोरी वर्कआउट होगा!
हम यह देखेंगे कि किसी भी दिए गए समय विंडो में कितने फ़ोरम ने "the most popular forum" का ख़िताब अपने नाम किया.
यह अभ्यास पाठ्यक्रम का हिस्सा है
इंटरमीडिएट Network Analysis in Python
अभ्यास निर्देश
- दिनवार सबसे लोकप्रिय फ़ोरम की सूची रखने के लिए
most_popular_forumsनाम की एक list बनाएँ. - सबसे लोकप्रिय फ़ोरम के degree centrality स्कोर रखने के लिए
highest_dcsनाम की एक list बनाएँ. G_subनाम का नया ग्राफ instantiate करें और.add_nodes_from()मेथड का उपयोग करके मूल ग्राफGसे nodes जोड़ें.- मूल ग्राफ G से वही edges जोड़ें जो मानदंडों को पूरा करते हैं (जो पिछले अभ्यास के बिल्कुल समान हैं).
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Import necessary modules
from datetime import timedelta
import networkx as nx
import matplotlib.pyplot as plt
# Instantiate a list to hold the list of most popular forums by day: most_popular_forums
most_popular_forums = ____
# Instantiate a list to hold the degree centrality scores of the most popular forums: highest_dcs
highest_dcs = ____
curr_day = dayone
td = timedelta(days=1)
while curr_day < lastday:
if curr_day.day == 1:
print(curr_day)
# Instantiate new graph: G_sub
G_sub = ____
# Add in nodes from original graph G
____
# Add in edges from the original graph G that fulfill the criteria
G_sub.____([(____, ____, ____) for ____, ____, ____ in ____ if d['____'] >= ____ and d['____'] < ____ + ____])
# CODE CONTINUES ON NEXT EXERCISE
curr_day += td