Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does igraph has "has_path" function?

Tags:

r

igraph

I am trying to port code from python NetworkX to R igraph. In NetworkX there is a function with the name has_path that finds if two vertices have a path. I want to find in an efficient way all the vertices of a graph that don't have an edge between them but they have a path.

like image 943
Dragno Avatar asked Apr 29 '26 02:04

Dragno


1 Answers

I think you can use the code below to check if there is a path from vertex V1 to V2 (the graph can be directed or undirected)

c(!is.infinite(distances(g, V1, V2, mode = "out")))
like image 132
ThomasIsCoding Avatar answered May 01 '26 16:05

ThomasIsCoding



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!