Invalid vertex id error using tidygraph

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

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

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?