# Invalid vertex id error using tidygraph

**URL:** <https://igraph.discourse.group/t/invalid-vertex-id-error-using-tidygraph/1233>\
**Category:** Usage\
**Tags:** R\
**Created:** [31 May 2022 06:19 UTC](https://igraph.discourse.group/t/invalid-vertex-id-error-using-tidygraph/1233 "2022-05-31T06:19:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DHARMA](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/dharma/32/531_2.png) [@DHARMA](https://igraph.discourse.group/u/DHARMA)\
**Post date:** [31 May 2022 06:19 UTC](https://igraph.discourse.group/t/invalid-vertex-id-error-using-tidygraph/1233/1 "2022-05-31T06:19:20Z")

</div>

Dear Sir

Presently I am working with the book "“Network Analysis & Visualisation in R Quick Start Guide.”  
OS Version R 4.1.1 on Mac . Tydigraph

The book has a illustrative case with data set NAVDATA, However when trying the same code as given in the book I get a problem as below

```nohighlight
library(tidygraph)
net.tidy<-tbl_graph(nodes=nodes,edges=edges, directed = T)

Error in (function (edges, n = max(edges), directed = TRUE) : At core/constructors/basic_constructors.c:75 : Invalid (negative) vertex id, Invalid vertex id

8.(function (edges, n = max(edges), directed = TRUE) { on.exit(.Call(C_R_igraph_finalizer)) if (missing(n) && (is.null(edges) || length(edges) == 0)) { ...
7.do.call(old_graph, args)
6.graph(t(el), directed = directed)
5.graph_from_edgelist(as.matrix(edges[, 1:2]), directed = directed)
4.as_graph_node_edge(x, directed = directed, node_key = node_key)
3.as_tbl_graph.list(list(nodes = nodes, edges = edges), directed = directed, node_key = node_key)
2.as_tbl_graph(list(nodes = nodes, edges = edges), directed = directed, node_key = node_key)
1.tbl_graph(nodes = nodes, edges = edges, directed = T)

```

Can you please guide me

Warm Regards

SHRINIVAS  
INDIA

---

<div class="post-metadata">

**Author:** ![GroteGnoom](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/grotegnoom/32/428_2.png) [@GroteGnoom](https://igraph.discourse.group/u/GroteGnoom)\
**Post date:** [31 May 2022 06:59 UTC](https://igraph.discourse.group/t/invalid-vertex-id-error-using-tidygraph/1233/2 "2022-05-31T06:59:36Z")

</div>

It seems like there’s something wrong with your edges, but I don’t know how your edges are constructed. Can you show me where the edges come from? Or is this all your code?
