There is some graph - represented as edges in some assoc.table, and 
they having some associated item with them (e.g. weight or length).

Is it possible to calculate the overall lenght of path from node to 
node (if there is a path at all) in SQL?

Finding if there is a path in the graph from node1 to node2, with max, 
say, 2 hops will look like:
FROM node as node1, node as node2, node as node3
   link as link1, link as link2
SELECT link1.length, 
WHERE node1.id == link1.in AND node2.id == link1.out    ##1 hop
   OR     node1.id == link1.in AND node2.id == link1.out 
      AND node2.id == link2.in AND node3.id == link2.out  ##2 hops

but i dont see how to also sum the link.length. or should i use UNION 
instead of OR?

This can be extended to any static number of hops... but is it 
possible to be done for a dynamic (unknown) number?

ciao
svil

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to