In article <43289c33-04b9-4cbc-9823-d8a4ee86d...@y33g2000prg.googlegroups.com>,
godshorse  <chinthak...@gmail.com> wrote:
>On May 13, 11:54=A0am, CTO <debat...@gmail.com> wrote:
>> On May 13, 12:10=A0am, godshorse <chinthak...@gmail.com> wrote:
>>
>> > Hello,
>>
>> > I want to find out the shortest path tree from a root to several nodes
>> > in a graph data structure. I found a Dijkstra code from internet that
>> > finds shortest path between only two nodes. How can i extend it to a
>> > tree?. And what is the best way to represent a tree in Python?.

<SNIP>

>
>Thanks very much for your reply Geremy. That site was interesting.
>
>Actually the Graph building part is already completed now. I used a
>dictionary for that and it works fine. for Dijkstra shortest path
>problem your suggestion can be used.
>
>But let me clear the my problem again. I have a graph. and I want to
>find 'shortest path tree' from a root node to several nodes. as a
>example if we have a graph of 5 nodes from 1 to 5, I need to build the
>shortest path tree from node 1 to nodes 2,3,5. So my question is
>instead of keeping separate lists for each destination node's shortest
>path. How can I represent and store them in a tree structure using
>python. Then I can easily find out what are the common nodes in the
>path to each destination.

If I understand correctly, you want to know the path given
the end-node. Common sense dictates that you use back links
if that has to be done with decent efficiency.
The back links can be added as part of the algorithm.

>
>Thanks once again.

Groetjes Albert

--
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- like all pyramid schemes -- ultimately falters.
alb...@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to