On 06.05.2015 13:56, ob wrote:
I am using random_graph() to generate graphs for given marginals. This seems to work well if the method does not need to create too many parallel edges. However, as soon as the marginals are significantly larger then the number of vertices the function tends to crash/hang up python. Here is a small example:
import graph_tool.all as gt in_degr =[50,40,3] out_degr=[40,3,50] g = gt.random_graph(3, lambda i: (in_degr[i],out_degr[i]), directed=True,parallel_edges=True)
I tried this on OS X and Linux with similar results. I'm not sure I have the right approach here. I'd rather prefer to have weighted edges created then parallel edges. But I couldn't figure out how to do that. I have two questions:
1. Can anyone reproduce / solve the issue above?
This is indeed a bug, and I can reproduce it. It must be able to wire the above graph. I'll provide a fix soon. (This problem disappears with self_loops=True, but that is probably not what you want.)
2. Is there a way to generate directed graphs from marginals with weighted edges?
That depends. If you only want random weights, all you need is a property map. But if you want the total sum of weights on each node to be a fixed quantity, you have to use parallel edges (or write your own code for weighted edges). Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>