I am trying to delete an edge from a graph.
I ran the following code
library(igraph)
A <- c(0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,1,0,0,0,0)
dim(A) <- c(5,5)
g1 <- graph_from_adjacency_matrix(t(A), mode = c("directed"))
g1 <- delete_edges(g1, c(1,2))
g1 <- simplify(g1)
coords <- c(0.0, 0.951056, 0.587785, -0.587785, -0.951056,
1, 0.309017, -0.809017,-0.809017, 0.309017)
dim(coords) <- c(5,2)
plot(g1,
vertex.color=c(rgb(0,.5,.7),
rgb(.15,.6,0),
rgb(.5,.5,.5),
rgb(.8,.55,0),
rgb(.8,0,0)),
vertex.size = 20,
layout = coords,
main = paste("Graph", toString(1)))
and produced the following
I would like the 1->2 edge to be deleted but the 2 ->3 edge to remain. Any ideas on what is happening and how to fix it?
