networkx

Visualizing time series data of graph nodes in plotly

北城余情 提交于 2021-02-08 04:38:23
问题 I've a graph created in Networkx and plotted using plotly Code: import numpy as np import pandas as pd import networkx as nx import matplotlib.pyplot as plt import plotly.graph_objects as go from pprint import pprint from collections import OrderedDict def get_edge_trace(G): edge_x = [] edge_y = [] for edge in G.edges(): x0, y0 = G.nodes[edge[0]]['pos'] x1, y1 = G.nodes[edge[1]]['pos'] edge_x.append(x0) edge_x.append(x1) edge_x.append(None) edge_y.append(y0) edge_y.append(y1) edge_y.append

Weighted Bimodal Bipartite Graph Projection conserving original weights

我的梦境 提交于 2021-02-08 03:08:15
问题 I have a large ( 36k vertices, 50k edges ) weighted bimodal bipartite graph and I would like to generate a projection that not only count the neighbors like the default weighted implementation but also sum the weights on the edges. You can think of it as a bipartite graph containing black vertices and blue vertices, where I want to conserve the original graph weights when there are only blue vertices. The implementations I came across keep the orange value, I am interested on the red one (or

Weighted Bimodal Bipartite Graph Projection conserving original weights

泄露秘密 提交于 2021-02-08 03:05:24
问题 I have a large ( 36k vertices, 50k edges ) weighted bimodal bipartite graph and I would like to generate a projection that not only count the neighbors like the default weighted implementation but also sum the weights on the edges. You can think of it as a bipartite graph containing black vertices and blue vertices, where I want to conserve the original graph weights when there are only blue vertices. The implementations I came across keep the orange value, I am interested on the red one (or

Python: how to color the nodes of a network according to their degree?

时光毁灭记忆、已成空白 提交于 2021-02-07 09:46:41
问题 I have a scale-free network made of 10000 nodes, but the texture of edges and the number of nodes make it too intricate to be made sense of. I want to be able to visually locate the most highly connected nodes. How could I color the nodes based on their degree k? Specifically, I would like to color them based on pre-assigned ranges, such as: Green if 1<k<10 ; Light blue if 11<k<20 ; Blue if 21<k<30 ; Purple if 31<k<40 ; ... Here is how I obtain the network: import networkx as nx import

Interaction between networkx and matplotlib

时光总嘲笑我的痴心妄想 提交于 2021-02-07 06:24:47
问题 I am trying networkx and visualization in matplotlib an I'm confused becouse I do not clearly understand how do they interact with each other? There simple example import matplotlib.pyplot import networkx as nx G=nx.path_graph(8) nx.draw(G) matplotlib.pyplot.show() Where do I tell pyplot, that I want to draw graph G? I guess that nx.draw use something like matplotlib.pyplot.{plot, etc ...} So, if I want to draw 2 graphs: import matplotlib.pyplot import networkx as nx G=nx.path_graph(8) E=nx

Node sizes not correct when drawing a graph with many components

左心房为你撑大大i 提交于 2021-02-07 04:00:50
问题 I've got a graph with many components which I would like to visualize. As a special feature, the node dots of the nodes in the giant component shall scale with their eigenvector centrality. All the other nodes have same size. I use the following script: import networkx as nx import pylab as py import matplotlib.pyplot as plt H = nx.read_gexf(input_file) print nx.info(H) #Name: #Type: Graph #Number of nodes: 719 #Number of edges: 620 #Average degree: 1.7246 # Set draw() parameters node_sizes =

Node sizes not correct when drawing a graph with many components

扶醉桌前 提交于 2021-02-07 03:59:04
问题 I've got a graph with many components which I would like to visualize. As a special feature, the node dots of the nodes in the giant component shall scale with their eigenvector centrality. All the other nodes have same size. I use the following script: import networkx as nx import pylab as py import matplotlib.pyplot as plt H = nx.read_gexf(input_file) print nx.info(H) #Name: #Type: Graph #Number of nodes: 719 #Number of edges: 620 #Average degree: 1.7246 # Set draw() parameters node_sizes =

Memory problems while code is running (Python, Networkx)

旧时模样 提交于 2021-02-07 03:42:57
问题 I made a code for generate a graph with 379613734 edges. But the code couldn't be finished because of memory. It takes about 97% of server memory when it go through 62 million lines. So I killed it. Do you have any idea to solve this problem? My code is like this: import os, sys import time import networkx as nx G = nx.Graph() ptime = time.time() j = 1 for line in open("./US_Health_Links.txt", 'r'): #for line in open("./test_network.txt", 'r'): follower = line.strip().split()[0] followee =

Memory problems while code is running (Python, Networkx)

隐身守侯 提交于 2021-02-07 03:41:13
问题 I made a code for generate a graph with 379613734 edges. But the code couldn't be finished because of memory. It takes about 97% of server memory when it go through 62 million lines. So I killed it. Do you have any idea to solve this problem? My code is like this: import os, sys import time import networkx as nx G = nx.Graph() ptime = time.time() j = 1 for line in open("./US_Health_Links.txt", 'r'): #for line in open("./test_network.txt", 'r'): follower = line.strip().split()[0] followee =

Python Reading from a file to create a weighted directed graph using networkx

情到浓时终转凉″ 提交于 2021-02-06 11:07:55
问题 I am new at python and Spyder. I am trying to read from a text file with format into a graph using networkx: FromNodeId ToNodeId Weight 0 1 0.15 0 2 0.95 0 3 0.8 0 4 0.5 0 5 0.45 0 6 0.35 0 7 0.4 0 8 0.6 0 9 0.45 0 10 0.7 1 2 0.45 1 11 0.7 1 12 0.6 1 13 0.75 1 14 0.55 1 15 0.1 ... I want to use Networkx graph format that can store such a large graph(about 10k nodes, 40k edges). import networkx as nx import matplotlib.pyplot as plt g = nx.read_edgelist('test.txt', nodetype=int, create_using=