| I'm not sure whether I would answer your problem correctly.
Couldn't you use any of the shortest path algorithms, like Dijkstra's
algorithm, with the cost between all vertices, if exist, to 1.
If you are interested in finding all-pairs paths, you could use
Floyd's algorithm. If you are interested in finding out just whether
this is a path between any 2 vertices, you could use Warshall's
algorithm to find the transitive closure.
I think these are all fairly standard algorithms. I think you could
find them in any graph theory books that talk about shortest-path
algorithms. There is a small section in
Aho, Hopcroft & Ullman, Data Structures and Algorithms
where I got these information from.
Hope I help you. I suspense there are other ways without using finding
the shortest path.
David
|
| I don't see why Dijkstra's algorithm (among others) wouldn't work.
Two implementations of Dijkstra's algorithm for undirected graphs are
SHORT.ADA and SHORT.C in TLE""::UPORT$:[AMARTIN]. (Another is SHORT.B36
on TLE""::UPORT$:[AMARTIN.VINO] and I've got one written in Rutgers
Pascal, probably on the TOPS20 cluster). I wrote the Pascal version
first, and then transformed it into Bliss-36. The Bliss-36 was transformed
into C and the C was transformed into Ada.
The programs assume that they are reading an undirected graph, but they
represent the graph as a digraph where any edge from vertex p to q is
matched by a vertex from q to p. It would be trivial to modify them
to simply not add the back edge when reading a graph. And I believe
that they would still work correctly on the resulting digraphs, even
if they were not even weakly connected. However, I never tried to verify
this.
A description of the distances between over 900 points in the Catskill,
Central and Adirondack regions of New York state is in [AMARTIN]NY.
on the above designated disk structure.
/AHM
|