Resolved: Test data has all possible edges in every community in an undirected graph

In this post, we will see how to resolve Test data has all possible edges in every community in an undirected graph

Question:

I am working with a list of edges in R:
I derived an igraph object from it:
and I have to test whether I have all the combinations between the vertices for every community in my data. I know every community should have nC2 edges, where n represents the number of nodes in the community, but I am not sure on how to do it with igraph.
In the example above, community 1 and 2 should be valid, as they have all the contribution between vertices, while community 3 shouldn’t.
How do I test this?
As the desired output, ideally I would like to have something like this:
or anything that would allow me to identify the incomplete pairs.
Thanks!

Best Answer:

You can use membership like below
which gives
where grp indicates how the vertices are clustered.

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com