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

डीप डाइव - Twitter नेटवर्क भाग II

अब आप betweenness centrality पर इसी तरह की एक डीप डाइव करने जा रहे हैं! बस कुछ संकेत: याद रखें कि betweenness centrality nx.betweenness_centrality(G) से निकाली जाती है.

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

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

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

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

  • एक फंक्शन find_node_with_highest_bet_cent(G) लिखें जो सबसे अधिक betweenness centrality वाले नोड/नोड्स को रिटर्न करे.
    • G की betweenness centrality निकालें.
    • list(bet_cent.values()) पर max() फंक्शन लगाकर अधिकतम betweenness centrality निकालें.
    • betweenness centrality की डिक्शनरी bet_cent.items() पर इटरेट करें.
    • यदि वर्तमान नोड k की betweenness centrality वैल्यू v max_bc के बराबर हो, तो उसे नोड्स के सेट में जोड़ें.
  • अपने फंक्शन का उपयोग करके T में सबसे अधिक betweenness centrality वाले नोड/नोड्स खोजें.
  • एक assertion स्टेटमेंट लिखें ताकि पक्का हो कि आपने सही नोड पाया है. यह आपके लिए कर दिया गया है, तो परिणाम देखने के लिए 'Submit Answer' पर क्लिक करें!

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

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

# Define find_node_with_highest_bet_cent()
def find_node_with_highest_bet_cent(G):

    # Compute betweenness centrality: bet_cent
    bet_cent = ____

    # Compute maximum betweenness centrality: max_bc
    max_bc = ____

    nodes = set()

    # Iterate over the betweenness centrality dictionary
    for k, v in ____:

        # Check if the current value has the maximum betweenness centrality
        if ____ == ____:

            # Add the current node to the set of nodes
            ____

    return nodes

# Use that function to find the node(s) that has the highest betweenness centrality in the network: top_bc
top_bc = ____
print(top_bc)

# Write an assertion statement that checks that the node(s) is/are correctly identified.
for node in top_bc:
    assert nx.betweenness_centrality(T)[node] == max(nx.betweenness_centrality(T).values())
कोड संपादित करें और चलाएँ