Following the reproducible example from HERE, what is the best way to add an edge (for example, V2 —> V3) to the plot.igraph()
, and that edge to be of different color
and lty
:
library(MASS)
library(pcalg)
library(igraph)
# Some variance-covariance
Corrs <- matrix(c(1.0,0.6,0.7,0.5,0.6,1.0,0.5,0.6,0.7,0.5,1.0,0.7,0.5,0.6,0.7,1.0), 4, 4)
SDs <- c(1.0,0.5,2.0,1.0)
Covs <- SDs %*% t(SDs) * Corrs
dat = as.data.frame(mvrnorm(100, mu=c(0,0,0,0), Sigma=Covs))
n = nrow(dat)
V = colnames(dat) # node names
pc1 = pc(suffStat=list(C=cor(dat), n=n),
indepTest=gaussCItest, # indep.test: partial correlations
alpha=0.05, labels=V, u2pd='retry')
gr = graph_from_graphnel(pc1@graph)
plot.igraph(gr, layout=layout_in_circle,
vertex.label=V, vertex.shape='circle', vertex.size=30,
vertex.label.cex=0.55, vertex.label.color='black',
edge.arrow.size=0.6)
If I do this with the edge()
function, following some examples from the package itself, then only an added edge is presented. Thus, that edge is not added (I also tried with the add_edges()
function with the same result):
gr = graph_from_graphnel(pc1@graph) + edge(2, 3, color='blue')
plot.igraph(gr, layout=layout_in_circle,
vertex.label=V, vertex.shape='circle', vertex.size=30,
vertex.label.cex=0.55, vertex.label.color='black',
edge.arrow.size=0.6)
Many thanks!