networkx

Can't install networkx for python 3.4

≯℡__Kan透↙ 提交于 2020-01-25 11:53:01
问题 After 3 days of trying to install networkx for python 3.4, I am on the verge of giving up and I've decided to seek for help from some of you people who had some experience with this perhaps. I managed to install networkx with easy_install or pip_install (I don't even remember anymore of how many times I've tried to install it all), but when I try to compile the very first, most basic piece of code (found in a tutorial): import networkx as nx; Test = nx.Graph(); Test.add_node("Test"); nx.draw

Can't install networkx for python 3.4

旧街凉风 提交于 2020-01-25 11:52:08
问题 After 3 days of trying to install networkx for python 3.4, I am on the verge of giving up and I've decided to seek for help from some of you people who had some experience with this perhaps. I managed to install networkx with easy_install or pip_install (I don't even remember anymore of how many times I've tried to install it all), but when I try to compile the very first, most basic piece of code (found in a tutorial): import networkx as nx; Test = nx.Graph(); Test.add_node("Test"); nx.draw

How to specify edge length in Networkx for calculating shortest distance?

时光总嘲笑我的痴心妄想 提交于 2020-01-24 10:23:10
问题 I have a list of nodes and edges but I want some edges to be of length two instead of one. So when the distance between the nodes is calculated using the built in algorithm it returns For example, if I have (1, 2), (2*, 3), (4*, 5) as edges between nodes, where the distance between the nodes with an asterisk have length two, the distance between (1, 2) should be 1, (2,3) should be 2 instead of 1 and then the distance between (1,5) should be 5 instead of 3. When adding nodes I've tried G.add

What is the optimal way to create a graph with add_edge_list() method?

纵饮孤独 提交于 2020-01-24 09:02:42
问题 I am trying to create large graph via graph-tool library (near 10^6 - 10^7 vertices) and fill vertex property with vertex name or use names instead of vertex indexes. I have: list of names: ['50', '56', '568'] set of edges, but instead of vertex indexes it consists of their names: edge_list = {frozenset({'568', '56'}), frozenset({'56', '50'}), frozenset({'50', '568'})} Since add_edge_list() allows to create vertices if they are no such vertix in the graph. I'm trying to use it to fill an

TypeError: 'NodeView' object does not support item assignment - NetworkX

半城伤御伤魂 提交于 2020-01-24 05:40:27
问题 I'm working through this tutorial: https://www.datacamp.com/community/tutorials/networkx-python-graph-tutorial import itertools import copy import networkx as nx import pandas as pd import matplotlib.pyplot as plt nodelist = pd.read_csv('https://gist.githubusercontent.com/brooksandrew/f989e10af17fb4c85b11409fea47895b/raw/a3a8da0fa5b094f1ca9d82e1642b384889ae16e8/nodelist_sleeping_giant.csv') g = nx.Graph() for i, nlrow in nodelist.iterrows(): g.node[nlrow['id']] = nlrow[1:].to_dict() ---------

How to draw parallel edges in Networkx / Graphviz

北城余情 提交于 2020-01-22 15:12:21
问题 I am trying to add parallel edges between two nodes using NetworkX but it fails with the below error. What am I doing wrong? import networkx as nx import graphviz g1 = nx.MultiGraph() node1 = 'a' node2 = 'b' g1.add_edge(node1,node2,key='one') g1.add_edge(node1,node2,key='two') A = nx.to_agraph(g1) A.add_subgraph() A.draw('test2.png', prog='dot') Error: Traceback (most recent call last): File "test2.py", line 12, in <module> A = nx.to_agraph(g1) File "C:\python27\lib\site-packages\networkx-1

How to delete all related nodes in a directed graph using networkx?

情到浓时终转凉″ 提交于 2020-01-22 12:44:50
问题 I'm not sure exactly sure what the correct terminology is for my question so I'll just explain what I want to do. I have a directed graph and after I delete a node I want all independently related nodes to be removed as well. Here's an example: Say, I delete node '11', I want node '2' to be deleted as well(and in my own example, they'll be nodes under 2 that will now have to be deleted as well) because its not connected to the main graph anymore. Note, that node '9' or '10' should not be

Hypergraph with networkx

a 夏天 提交于 2020-01-20 08:39:50
问题 is anyone familiar with networkx? I try to get a hypergraph, where i want to set the Hyperedges as other colored nodes (size dependent on their value) out of an list. And i want to set the Nodes out of an other list. The documentation and examples on the networkx website are really spare, but i am sure it is possible. I started with this example, but this is only an example for different edges. Can someone tell me how i can put up two different set of nodes with different color/size in

AttributeError in NetworkX, module has no max_clique attribute [closed]

会有一股神秘感。 提交于 2020-01-20 07:49:26
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . like said in the title I have an attribute error. Here is my code: from sympy import * import numpy as np import networkx as nx G=nx.Graph() with open ("testing.txt", "r") as myfile: Matrice=eval(myfile.readline()) Matnum = np.array(np.array(Matrice)) Matnum = Matnum.astype(np.int, copy=False) G.add_node(Matnum

AttributeError in NetworkX, module has no max_clique attribute [closed]

╄→гoц情女王★ 提交于 2020-01-20 07:48:45
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . like said in the title I have an attribute error. Here is my code: from sympy import * import numpy as np import networkx as nx G=nx.Graph() with open ("testing.txt", "r") as myfile: Matrice=eval(myfile.readline()) Matnum = np.array(np.array(Matrice)) Matnum = Matnum.astype(np.int, copy=False) G.add_node(Matnum