SPA - Best way of implementation

Andreas Mallek mallek at regfish.com
Sat Jun 5 14:17:15 CEST 2004


hello,

i'm looking for a good method to create an short
path algorithm like dijkstra. well.. i hope that
i can find someone that already integrated spa's
with python.

my goal is to find ways from contact-person A to
contact-person B. but i have to save and sort 
all the possible ways in a depth of about nine
max hops like this:

user A knows user K
user K knows user R
user R knows user B and C
user B knows user I
user I knows user C

now i'm looking for a way from a to c:

   A -> K -> R -> C
      or
   A -> K -> R -> B -> I -> C


target usage:

<< FROM    = 'A'
<< TO      = 'C'
<< MAXHOPS = 9
<< ways = []
<< ways = find(FROM,TO,MAXHOPS)
<< print ways
>> [{'A','K','R','C'},{'A','K','R','B','I','C'}]

:-)


so guys.. any ideas for a short, fast and
"simple" implementation with about 20 lines of code? :-)

greetings
andy




More information about the Python-list mailing list