Edge between all nodes in NetworkX Graph

Viewed 2953

I am able to add an edge between any two individual node like below:

G.add_edge(node1, node)

But if I wanted to and edge between any two nodes (All nodes should be adjacent to each other) it becomes difficult when large number of nodes are taken.

Example: If number are nodes are four and they are 1,2,3,4.The Graph should look like this enter image description here

For above graph I am adding nodes as follow:

graph = [(1, 2),(1, 3),(1, 4), (2, 3),(2, 4), (3, 4)]
for edge in graph:
        G.add_edge(edge[0], edge[1])

Is there any default option as parameter in Graph construction for my requirement?

Basically I need to construct a clique for given nodes.

Thanks

1 Answers
Related