Then I use it in two different (and in my opinion, equivalent) ways:
G = gt.random_graph(500, lambda : deg_samp(3), directed = False)
G = gt.random_graph(500, deg_samp, directed = False)
I expect both these graphs to be similar. However, I find that the second
one is extremely dense and its average degree far exceeds 3. I am quite
confused about this.
The function random_graph() will look at how many parameters the deg_sampler
takes, and this will trigger different behaviors. From the documentation:
A degree sampler function which is called without arguments, and
returns a tuple of ints representing the in and out-degree of a given
vertex (or a single int for undirected graphs, representing the
out-degree). This function is called once per vertex, but may be called
more times, if the degree sequence cannot be used to build a graph.
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.
Your first example will trigger the behavior in the first paragraph, while
the second will trigger the behavior in the second paragraph.
Although it is in fact documented, I agree this is confusing and unexpected.
Please open an issue in the website, and this will be improved in the future.