# Adding edge to a graph

**URL:** <https://igraph.discourse.group/t/adding-edge-to-a-graph/1841>\
**Category:** Usage\
**Tags:** R\
**Created:** [4 August 2024 11:49 UTC](https://igraph.discourse.group/t/adding-edge-to-a-graph/1841 "2024-08-04T11:49:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![striatum](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/striatum/32/1090_2.png) [@striatum](https://igraph.discourse.group/u/striatum)\
**Post date:** [4 August 2024 11:49 UTC](https://igraph.discourse.group/t/adding-edge-to-a-graph/1841/1 "2024-08-04T11:49:31Z")

</div>

Following the reproducible example from [HERE](https://igraph.discourse.group/t/warning-message-is-r-is-deprecated/1837), 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`:

```auto
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):

```auto
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!
