last day (16 days later) » 

11:07 AM
0
Q: waxman_graph in networkx does not add edges

PauloI am using waxman_graph in Networkx to simulate real-world networks. I try to add edges with random weights but it does not work with waxman_graph model while it works with connected_watts_strogatz_graph. import networkx as nx import random x=10 y=10 dist = lambda x, y: sum(abs(a - b) for a, b ...

 
What goes wrong? Do you get an error message?
 
@Joel no error message
@Joel I tried and removed all the optional parameters , still does not work. I tested if there are links but they are not visible , still does not work. No edges at all.
 
So how do you know it doesn't work? What goes wrong?
 
@Joel I tested it with Dijkstra to see if there is any edge .
 
When I run your code I get a message that nodes is not defined.
 
11:07 AM
@Joel oh, just add any number of nodes,let me modify it.
 
So it seems to work for me. Only 3 edges in the run I did, but that's a consequence of the edge probability being very low.
 
@Joel oh, which Networkx version you use?
 
2.2, but I expect the same in other versions.
 
Hi Joel
I am using last version of Networkx
 
To check the number of edges use g.size()
 
11:09 AM
It gives number of edges?
 
yes
You probably have a few edges, but the parameters you've chosen probably make the number of edges small
 
Ha
You mean the third parameter ? 0.1
I will try the same code on another device . I will let you know the result . Thank you very much Joel.
 
The distance function, beta, and alpha all affect the edge probability. You've probably just got small edge probabilities so only a few edges appear.
Also, since the waxman graph already has an underlying geometry to it, I wouldn't use spring layout. Instead do
pos = dict(g.nodes(data='pos'))
 
Okay, I will try them
 

  last day (16 days later) »