0

I want to generate a random graph using the edge distribution from the original graph. Is there a way in networkx module to do that?

1 Answer 1

1

I'm assuming you mean same degree distribution.

The command nx.configuration_model(degree_list) will do it.

So in your case, given an existing graph G:

H = nx.configuration_model([G.degree(node) for node in G])
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks! Also, is there any way I could fit it to a particular distribution? Say, if I wanted to fit it to a hypergeometric distribution.
As in the degree distribution be from a particular distribution? Yes - you generate a degree list using whatever distribution.
It would be great if you could probably add a code snippet on how to do that? I am just getting started with networkx. Cheers~
Instead of [G.degree(node) for node in G] in the argument for nx.configuration_model, you'll need to create a list, say L whose entries come from whatever distribution you want. Depending on what that distribution is, you would need to generate L. Then you just use nx.configuration_model(L)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.