networkx

Separate edge arrows in python/networkx directed graph

走远了吗. 提交于 2021-01-04 03:26:32
问题 I would like to obtain something similar to this: using the python library networkx. I can generate a similar directed graph using the following code: import matplotlib.pyplot as plt import networkx as nx G = nx.DiGraph() G.add_edge('1','2') G.add_edge('1','3') G.add_edge('3','2') G.add_edge('3','4') G.add_edge('4','3') nx.draw(G, node_color='w', edgecolors='k', width=2.0, with_labels=True) plt.show() which produces: However, the arrows between the nodes 3 and 4 are superimposed, and it just

Error displaying Edge labels from pandas dataframe networkx/ error with pos values. dont know which is it

南笙酒味 提交于 2020-12-15 05:16:50
问题 My dataframe has 3 columns, source , target and value. it looks like this source target value BOBA FETT C-3PO 4 BOBA FETT CHEWBACCA 3 BOBA FETT DARTH VADER 8 BOBA FETT HAN 7 G = nx.from_pandas_edgelist(links,source='source',target='target', edge_attr='value') I use this to add my edgelist nx.draw_networkx_edge_labels(G,pos=nx.Graph(G),edge_labels={(u,v):w for u,v,w in G.edges(data='value')}) I tried this to show edge labels. I want the 'value' to be dispplayed as my edge label it gives this

Error displaying Edge labels from pandas dataframe networkx/ error with pos values. dont know which is it

╄→尐↘猪︶ㄣ 提交于 2020-12-15 05:15:39
问题 My dataframe has 3 columns, source , target and value. it looks like this source target value BOBA FETT C-3PO 4 BOBA FETT CHEWBACCA 3 BOBA FETT DARTH VADER 8 BOBA FETT HAN 7 G = nx.from_pandas_edgelist(links,source='source',target='target', edge_attr='value') I use this to add my edgelist nx.draw_networkx_edge_labels(G,pos=nx.Graph(G),edge_labels={(u,v):w for u,v,w in G.edges(data='value')}) I tried this to show edge labels. I want the 'value' to be dispplayed as my edge label it gives this

Get all nodes inside only one of the Polygons, OSMNX

*爱你&永不变心* 提交于 2020-12-15 04:40:27
问题 I have a network formed with two Polygons and I want to now which nodes are only in the bigger Polygon. How can I do this? Here is the code: import osmnx as ox import igraph as ig import matplotlib.pyplot as plt import pandas as pd import networkx as nx city = ['Portugal, Lisbon', 'Portugal, Amadora'] G = ox.graph_from_place(city, network_type='drive', simplify=True) G_nx = nx.relabel.convert_node_labels_to_integers(G) nodes, edges = ox.graph_to_gdfs(G_nx, nodes=True, edges=True) Here are the

Get all nodes inside only one of the Polygons, OSMNX

允我心安 提交于 2020-12-15 04:38:05
问题 I have a network formed with two Polygons and I want to now which nodes are only in the bigger Polygon. How can I do this? Here is the code: import osmnx as ox import igraph as ig import matplotlib.pyplot as plt import pandas as pd import networkx as nx city = ['Portugal, Lisbon', 'Portugal, Amadora'] G = ox.graph_from_place(city, network_type='drive', simplify=True) G_nx = nx.relabel.convert_node_labels_to_integers(G) nodes, edges = ox.graph_to_gdfs(G_nx, nodes=True, edges=True) Here are the

KeyError when assign colours to nodes

限于喜欢 提交于 2020-12-15 04:33:11
问题 I am getting a KeyError when I try to create a network. My dataset is Node Neighbors Colour Weight Luke Alte orange 3 Luke John orange 3 Michael Laura red 43 Ludo Stella orange 21 Alte Ludo blue 24 Alte Luke blue 24 The table above shows the links by nodes: node Luke is linked with Alte and John. It has edge weight 3 and colour orange node Michael is linked with Laura. It has weight 43 and colour red node Ludo is linked with Stella. It has weight 21 and colour orange node Alte is linked with

how to plot a networkx graph using the (x,y) coordinates of the points list?

落爺英雄遲暮 提交于 2020-12-13 03:21:31
问题 I have points as x,y and I want to plot my graph using the (x,y) coordinates of my points list so that I can see the axis. here are my code and photo of the graph import networkx as nx import matplotlib.pyplot as plt def add_edge_to_graph(G,e1,e2,w): G.add_edge(e1,e2,weight=w) G=nx.Graph() points=[(1, 10), (8, 10), (10, 8), (7, 4), (3, 1)] #(x,y) points edges=[(0, 1, 10), (1, 2, 5), (2, 3, 25), (0, 3, 3), (3, 4, 8)]#(v1,v2, weight) for i in range(len(edges)): add_edge_to_graph(G,points[edges

How to remove float('nan') node from a graph in networkx?

≡放荡痞女 提交于 2020-12-12 09:51:03
问题 I have a dataset(pickle format) containing float('nan') , and I need to remove it. It is possible to add float('nan') to a graph as a node in networkx. However, I don't know how to remove it. import networkx as nx G = nx.Graph() G.add_node(float('nan')) print(G.nodes) # [nan], so there is float('nan') in the graph G.remove_node(float('nan')) # this statement raise a NetworkxError showing nan not in the graph Code and data in CoReRank-WSDM-2019 and BirdNest. Could anyone help me with this

How to remove float('nan') node from a graph in networkx?

◇◆丶佛笑我妖孽 提交于 2020-12-12 09:50:49
问题 I have a dataset(pickle format) containing float('nan') , and I need to remove it. It is possible to add float('nan') to a graph as a node in networkx. However, I don't know how to remove it. import networkx as nx G = nx.Graph() G.add_node(float('nan')) print(G.nodes) # [nan], so there is float('nan') in the graph G.remove_node(float('nan')) # this statement raise a NetworkxError showing nan not in the graph Code and data in CoReRank-WSDM-2019 and BirdNest. Could anyone help me with this

How to remove float('nan') node from a graph in networkx?

☆樱花仙子☆ 提交于 2020-12-12 09:50:10
问题 I have a dataset(pickle format) containing float('nan') , and I need to remove it. It is possible to add float('nan') to a graph as a node in networkx. However, I don't know how to remove it. import networkx as nx G = nx.Graph() G.add_node(float('nan')) print(G.nodes) # [nan], so there is float('nan') in the graph G.remove_node(float('nan')) # this statement raise a NetworkxError showing nan not in the graph Code and data in CoReRank-WSDM-2019 and BirdNest. Could anyone help me with this