Re: all paths between 2 nodes
From: Jim Nastos (nastos_at_cs.ualberta.ca)
Date: 04/10/04
- Next message: Michael Mendelsohn: "Re: all paths between 2 nodes"
- Previous message: Glenn C. Rhoads: "Re: all paths between 2 nodes"
- In reply to: Glenn C. Rhoads: "Re: all paths between 2 nodes"
- Next in thread: Michael Mendelsohn: "Re: all paths between 2 nodes"
- Reply: Michael Mendelsohn: "Re: all paths between 2 nodes"
- Reply: Glenn C. Rhoads: "Re: all paths between 2 nodes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 10 Apr 2004 01:56:30 -0600
On 9 Apr 2004, Glenn C. Rhoads wrote:
> Now I fully understand what you mean but I have to point
> out that this is not an improvement. When finding the
> number of paths to B, the version I described does one
> addition at each of the nodes A, D, E, and F; your version
> waits until you get to B and then does all the additions.
But every time you "update" B, you will have to update
any values that also depend on B (i.e. any other values
that B points to and that you've already written a label
for.)
> Also, I was tacitly assuming the most usual graph
> representation, namely an adjacency list of outgoing
> edges for each node. Under this representation, you
> can't efficiently perform the algorithm as you described
> it.
Actually, one could easily implement this algorithm.
The usual adjacency list can find a topsort in O(m+n)
time and then using that vertex ordering, one never needs to
find all in-edges because one can just add to the outedges
exactly once per edge provided the nodes are processed in the
order provided by the topsort.
J
- Next message: Michael Mendelsohn: "Re: all paths between 2 nodes"
- Previous message: Glenn C. Rhoads: "Re: all paths between 2 nodes"
- In reply to: Glenn C. Rhoads: "Re: all paths between 2 nodes"
- Next in thread: Michael Mendelsohn: "Re: all paths between 2 nodes"
- Reply: Michael Mendelsohn: "Re: all paths between 2 nodes"
- Reply: Glenn C. Rhoads: "Re: all paths between 2 nodes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|