Check whether two vertices are connected using graph-tool on Python

642 Views Asked by At

Is there a method in graph-tool through which checking whether two nodes are connected (as first neighbours) or not without having to iterate?

For example, something like graph_tool.is_connected(v,u) which returns a boolean depending on whether v and u are or not connected vertices. Something like a function to check just whether a certain edge exists.

Thanks

1

There are 1 best solutions below

1
Pablo On

It is solved by checking the result of the function g.edge(v,u). If add_missing=False it just returns None whenever the edge does not exist. Thanks to @NerdOnTour for the comment