Reputation: 715
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:
n
(int or iterable container of nodes) – If n
is an integer, nodes
are from range(n)
. If n
is a container of nodes, those nodes appear
in the graph.
create_using
(Graph, optional (default None)) – If provided this
graph is cleared of nodes and edges and filled with the new graph.
Usually used to set the type of the graph.
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
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