I have the following undirected star graph:
> g2
IGRAPH 722b7c9 DN-- 5 8 --
+ attr: name (v/c)
+ edges from 722b7c9 (vertex names):
[1] V1->V2 V1->V3 V1->V4 V1->V5 V2->V1 V3->V1 V4->V1 V5->V1
Which I want to turn into:
[1] 1->2 1->3 1->4 1->5 2->1 3->1 4->1 5->1
I tried using as_edgelist
with names = FALSE
to get rid of the names.
unnameGraph <- function(graphToPlot){
edgeListG2 <- as_edgelist(graphToPlot, names = FALSE)
return(make_graph(edgeListG2))
}
But it's giving me the wrong edge list and destroying the star graph:
[1] 1->1 1->1 2->3 4->5 2->3 4->5 1->1 1->1
Why?