Random graph with degree sequence.

Hi,

I'm using graph-tool to try to generate random graphs with a sequence of
degrees. For example, in a 3-node graph, I generated a random graph with
all nodes with input degrees 1 and output degrees 1.

My code:

import graph_tool.all as gt>>> def deg_sampler():... return 1,1... >>> g = gt.random_graph(3,deg_sampler,parallel_edges=True, self_loops=False)>>> gt.graph_draw(g)

Can I generate a random graph defining the input and output degrees of each
node? For example, tree nodes with respectively the input degrees (1, 2, 0)
and output degrees (1, 0, 2).

Thanks,

Alvaro

attachment.html (1.37 KB)

Ni!
Hi Alvaro, this is explained in the documentation for the
graph_tool.generation.random_graph
<graph_tool.generation — graph-tool 2.58 documentation;
function concerning the `deg_sampler`:

Optionally, you can also pass a function which receives one or two
arguments. If block_membership is None, the single argument passed will
be the index of the vertex which will receive the degree. If
block_membership is not None, the first value passed will be the vertex
index, and the second will be the block value of the vertex.

Cheers,
.~´

attachment.html (3.17 KB)