zoukankan      html  css  js  c++  java
  • 拓端tecdat|python编程代写对网络图networkx进行社区检测和彩色绘图

    原文链接:http://tecdat.cn/?p=7598

    以下是创建图表,检测其中的社区,然后在少于10行的python中使用由其社区着色的节点进行可视化的方法:

    import networkx as nx
    import community
    
    G = nx.random_graphs.powerlaw_cluster_graph(300, 1, .4)
    
    part = community.best_partition(G)
    values = [part.get(node) for node in G.nodes()]
    
    nx.draw_spring(G, cmap = plt.get_cmap('jet'), node_color = values, node_size=30, with_labels=False)

    模块化很容易实现

    mod = community.modularity(part,G)
    print("modularity:", mod)

    给了modularity: 0.8700238252368541

     

    如果您有任何疑问,请在下面发表评论。 

    ▍关注我们 【大数据部落】第三方数据服务提供商,提供全面的统计分析与数据挖掘咨询服务,为客户定制个性化的数据解决方案与行业报告等。 ▍咨询链接:http://y0.cn/teradat ▍联系邮箱:3025393450@qq.com
  • 相关阅读:
    Remove Linked List Elements
    Count Primes
    Isomorphic Strings
    Read N Characters Given Read4 II
    Word Ladder II Graph
    Word Ladder
    Binary Tree Right Side View
    House Robber
    Find non-overlap jobs with max cost
    Find Peak Element
  • 原文地址:https://www.cnblogs.com/tecdat/p/11670275.html
Copyright © 2011-2022 走看看