networkx

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

五迷三道 提交于 2021-02-06 11:06:52
问题 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=

How to reshape a networkx graph in Python?

我是研究僧i 提交于 2021-02-05 18:17:47
问题 So I created a really naive (probably inefficient) way of generating hasse diagrams. Question: I have 4 dimensions... p q r s . I want to display it uniformly (tesseract) but I have no idea how to reshape it. How can one reshape a networkx graph in Python? I've seen some examples of people using spring_layout() and draw_circular() but it doesn't shape in the way I'm looking for because they aren't uniform. Is there a way to reshape my graph and make it uniform? (i.e. reshape my hasse diagram

How to reshape a networkx graph in Python?

断了今生、忘了曾经 提交于 2021-02-05 18:11:55
问题 So I created a really naive (probably inefficient) way of generating hasse diagrams. Question: I have 4 dimensions... p q r s . I want to display it uniformly (tesseract) but I have no idea how to reshape it. How can one reshape a networkx graph in Python? I've seen some examples of people using spring_layout() and draw_circular() but it doesn't shape in the way I'm looking for because they aren't uniform. Is there a way to reshape my graph and make it uniform? (i.e. reshape my hasse diagram

OSMNX graph_from_gdfs KeyError: 'x' when converting a Geopackage to a Graph

房东的猫 提交于 2021-02-05 11:35:07
问题 I need to edit data downloaded by osmnx in geopackage format and then import it as a graph for calculating distances, isochrones etc. Current Process: Download osm data using ox.graph_from_point Save to Geopackage edges and nodes using ox.io.save_graph_geopackage, to allow user to add edges, extra roads in QGIS by digitising roads (with snapping) and save edits. Convert edited edges back to OSMNX as a graph using ox.graph_from_gdfs. At this point the 'ox.graph_from_gdfs' returns an empty

Create a tree structure from a graph

三世轮回 提交于 2021-02-05 06:40:05
问题 I'm trying to find the right approach to graphing a dataset that contains information on amount of time users typically spend in various locations. Importantly, there are categories and subcategories with increasing levels of granularity to my data (for example, 60% of people are at "home", and of those 40% are in the "living room"). I am aware of TreeMaps which would display the information and relationships I need, but I have been asked to make a "network" visualization of the data. What I

Networkx drawing label partially outside the box

浪子不回头ぞ 提交于 2021-02-04 18:56:13
问题 Just draw a very simple 4-node network, import networkx as nx import matplotlib.pyplot as plt G = nx.Graph() node1 = "116.251.211.248" node2 = "5.79.100.165" node3 = "http.anturis.com" node4 = "s411993.ip-37-187-141.eu" G.add_node(node1) G.add_node(node2) G.add_node(node3) G.add_node(node4) G.add_weighted_edges_from([(node1, node2, 0.742345), (node1, node3, 0.916954), (node1, node4, 0.662011), (node1, node4, 0.818537), (node2, node3, 0.947824), (node2, node4, 0.800774), (node3, node4, 0

Group nodes together in networkx

一笑奈何 提交于 2021-02-04 18:17:57
问题 I have a visualization problem involving a graph. I have N nodes, which belong to say some M networks. The nodes can have inter-network edges (within the same network) and intra-network edges (edges from a node in one network to another one). When I visualize the graph in networkx I am looking for a way to place/cluster the networks together so that I can easily make out the inter/intra network connections. So ideally all the blue nodes would be clustered together as network (in no particular

Group nodes together in networkx

痞子三分冷 提交于 2021-02-04 18:17:05
问题 I have a visualization problem involving a graph. I have N nodes, which belong to say some M networks. The nodes can have inter-network edges (within the same network) and intra-network edges (edges from a node in one network to another one). When I visualize the graph in networkx I am looking for a way to place/cluster the networks together so that I can easily make out the inter/intra network connections. So ideally all the blue nodes would be clustered together as network (in no particular

How to set a maximum value in a color map of a network (Python)

左心房为你撑大大i 提交于 2021-01-29 18:24:33
问题 Imagine you have a network of 10 nodes and the nodes value is values = [i for i in range(len(10))] Now I want to color this network however, I only want a color map of the nodes that have a value less than 5 . How do I do this? Thank you in advance. 回答1: For that, you can simply not include (filte out) those nodes you want to avoid when plotting in nx.draw . If you do want to include them, though just without a colormap (perhaps a constant color), just use a constant color rather than

Plotting the graph in networkx from the numpy array

痴心易碎 提交于 2021-01-29 13:14:07
问题 I have a DataFrame in pandas with information about people location in time. It is about 300+ million rows. Here is the sample where each Name is assigned to a unique index by group.by and sorted by "Name" and "Year": import pandas as pd inp = [{'Name': 'John', 'Year':2018, 'Address':'Beverly hills'}, {'Name': 'John','Year':2018, 'Address':'Beverly hills'}, {'Name': 'John', 'Year':2019, 'Address':'Beverly hills'}, {'Name': 'John', 'Year':2019, 'Address':'Orange county'}, {'Name': 'John',