Python+;网络图:处理大量节点

Python+;网络图:处理大量节点,python,networking,graph,analytics,networkx,Python,Networking,Graph,Analytics,Networkx,我正在使用Networkx创建具有20-50k个节点以及它们之间大量连接的图。 我在这个图中的主要目标是快速找到连接到许多其他节点的节点。 我正在使用两种主要的节点类型:“account”(黑色)和“attribute”(红色) 我遇到的问题是,生成的图表不容易阅读,它们太“紧”。 我尝试过使用shell_布局和使用这种“节点类型”分段的二分布局,但结果根本不可读 是使用较少节点的唯一解决方案吗? 你对我的问题有什么建议吗 一个很好的选择:对于连接更紧密的节点,边缘更暗 非常感谢你 代码摘录:

我正在使用Networkx创建具有20-50k个节点以及它们之间大量连接的图。 我在这个图中的主要目标是快速找到连接到许多其他节点的节点。 我正在使用两种主要的节点类型:“account”(黑色)和“attribute”(红色)

我遇到的问题是,生成的图表不容易阅读,它们太“紧”。 我尝试过使用shell_布局和使用这种“节点类型”分段的二分布局,但结果根本不可读

是使用较少节点的唯一解决方案吗? 你对我的问题有什么建议吗

一个很好的选择:对于连接更紧密的节点,边缘更暗

非常感谢你

代码摘录:

G = nx.from_pandas_edgelist(all_edges, source = "attribute", target = "account")

G.add_nodes_from(all_nodes[all_nodes['type']=='acc'].set_index('node'))
G.add_nodes_from(all_nodes[all_nodes['type']=='att'].set_index('node'))
nx.set_node_attributes(G,pd.Series(all_nodes.set_index('node').type).to_dict(),'type')

account_nodes = [n for (n,ty) in \
    nx.get_node_attributes(G,'type').items() if ty == 'acc']

attribute_nodes = [n for (n,ty) in \
    nx.get_node_attributes(G,'type').items() if ty == 'att']

shells = [account_nodes, attribute_nodes]
pos = nx.shell_layout(G, shells)

nx.draw_networkx_nodes(G, pos, nodelist=account_nodes,
                       node_size=30, alpha=1, linewidths=2, width=5,
                       node_color='black', node_shape='o')

nx.draw_networkx_nodes(G, pos, nodelist=attribute_nodes,
                       node_size=10,alpha=0.4, linewidths=2, width=5,
                       node_color='red', node_shape='x',)

nx.draw_networkx_edges(G, pos, width=0.1, edge_color='blue', style='solid', alpha=0.2)
两部分示例:

shell示例: