Travis Black
Travis Black

Reputation: 715

NetworkX generating a complete graph from a list of nodes

I have been using NetworkX to find maximal cliques in a graph. I am trying to take these cliques, and create new graphs, which I then want to add new nodes and edges to.

max_cliques = list(nx.find_cliques(mygraph)) //outputs list of lists of cliques
for clique in max_cliques:
    mygraph = nx.Graph()
    mygraph.add_nodes_from(clique)
    mygraph = nx.complete_graph(clique)

When I do this, I receive the following error:

TypeError: range() integer end argument expected, got list.

I don't really follow, because the networkx docs say this about complete_graph's parameters:

I've tried a few variations of this but they all give me the same error if I try to use an iterable to populate my complete graph. Can someone fill me in on what Iam doing wrong?

Thanks.

Upvotes: 0

Views: 1278

Answers (1)

Travis Black
Travis Black

Reputation: 715

My problem was that I was using an old version of NetworkX. I upgraded to 2.1, and it now works.

Upvotes: 2

Related Questions