Reputation: 22
I use function max_cliques in R from package igraph to get cliques from a social network using the following commands.
edges<-read.csv2("edges.csv", header = TRUE, sep = ",")
nodes<-read.csv2("nodes.csv", header = TRUE, sep = ",")
graph <- graph_from_data_frame(edges, directed=FALSE, vertices=nodes)
mc<-max_cliques(graph, min = 4, max = NULL, subset = NULL, file = "output_clique.csv" )
All works fine except the fact that I receive in the output file new ids of vertices that I cannot handle. I've read the documentation of the package. They speak about it but doesn't seem to give a solution about it.
Somme propositions ?
Upvotes: 0
Views: 664
Reputation: 48071
igraph uses vertex IDs starting from 1 up to the number of vertices (at least in R), no matter what the original IDs were in the data frame. The original IDs of the data frame are stored in an appropriate vertex attribute. V(g)$name
gives you the original vertex IDs in a vector; you can then index this vector with the numbers that max_cliques
gives you to get the original vertex IDs.
For instance, if max_cliques
gave you c(1,2,3,4)
as a clique, you can run V(g)$name[c(1,2,3,4)]
to get the original IDs.
Upvotes: 1