Reputation: 27
I am using igraph and trying to delete few vertices.When I try to delete vertex 77, I see vertex 78 which is connected to it being deleted rather than 77 itself...
library(graph)
out <- read.csv("~/Downloads/adj/out.adjnoun_adjacency_adjacency", sep="")
out.network<-graph.data.frame(out,directed = FALSE)
x<-delete_vertices(out.network,c(77))
plot(x)
Why is this.. Am I making mistake
Upvotes: 0
Views: 844
Reputation: 4586
Are you sure vertex #78
gets deleted? igraph
vertex indices are always continuous, so if you delete #77
the former #78
becomes the new #77
, and the graph won't have #78
any more. We can demonstrate this with a vertex attribute corresponding to the indices before the deletion. The example below verifies that the original vertex #78
has the index #77
after deleting #77
:
library(igraph)
g <- barabasi.game(n = 78, m = 3)
V(g)$original_index <- seq(1:vcount(g))
V(g)$original_index
V(g)$original_index[77]
[1] 77
g <- delete.vertices(g, c(77))
V(g)$original_index[77]
[1] 78
Upvotes: 1