[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] testing if two nodes are connected
From: |
Tamás Nepusz |
Subject: |
Re: [igraph] testing if two nodes are connected |
Date: |
Sat, 15 Feb 2014 09:36:18 +0100 |
> However, there is still could be a path between the two vertices. How can I
> check that a path does not exist and the two vertices are not disconnected?
Use shortest_paths(source=v1, target=v2). You’ll get a 1x1 matrix as a result;
if its only entry is finite, you have a path between v1 and v2, otherwise you
don’t. If you plan to do this for many vertex pairs, you can also calculate the
connected components of the graph using clusters(mode=“weak”) or
clusters(mode=“strong”). Any two nodes in the same strongly connected component
are mutually reachable from each other.
T.