Jenna Maiz
Jenna Maiz

Reputation: 812

Faster way to create a Complete graph?

So I have a list of names which I use to create a graph. Each name is a node on the graph and the edges are weighted with the minimum edit distance between the names. For my task, I have to create a weighted edge between each name. I have nested for loop to do this and it takes a long time for my program to build the graph. Is there a faster way to accomplish this ?

Upvotes: 0

Views: 2050

Answers (1)

eerorika
eerorika

Reputation: 238421

There will be O(n^2) edges when you create one between all vertices (a complete graph). You can't have lesser complexity than that.

Upvotes: 1

Related Questions