Re: Finding simple cycles approximating target distance



In article <1136885432.085264.66410@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
KoenM <rockinfewl@xxxxxxxxx> wrote:
>Hi all,
>
>Thinking about developing a bicycle route finder, I'm not sure how to
>best solve the following problem relating graph theory.
>
>Given a directed weighted graph, and a specific vertex as starting
>point, how do I find simple cycles approximating some target distance,
>most efficiently?
>>>From the graph at hand, I expect result cycles will consist of about 10
>to 100 edges.
>
>I guess I'm after 'simple' cycles here, to make sure I get
>'interesting' cycles to bike, and not heavily zigzagging ones that pass
>the same point multiple times?
>
>Any pointers or algorithms you have in mind?

Assuming the weights are all positive and you want the total weight
in the interval [a,b], you can do a depth-first search using the
following pseudo-code.
I assume neighbours(x) for node x returns the set of nodes y such
that x -> y is an arc of your digraph.

searchit:= proc(s,t,A,lo,hi)
# find a path from s to t of total weight in [lo,hi], avoiding
# vertices in A
for y in neighbours(s) minus A do
w := weight(s -> y)
if y = t then
if w >= lo and w <= hi then return (s,t)
else if w <= hi then
temp := searchit(y, t, A union {y}, lo - w, hi - w)
if temp <> NULL then return (s,temp)
return NULL

And call it with

searchit(startpoint,startpoint,{},a,b)

Robert Israel israel@xxxxxxxxxxx
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia Vancouver, BC, Canada
.



Relevant Pages

  • Re: How come Ada isnt more popular?
    ... The difference is between a) graph treated as a mesh of nodes which "own" each other and b) graph treated as a collection of nodes. ... The former might have ownership cycles between nodes, but not the latter, where ownership is an acyclic relation between graph and nodes. ... there is a strong argument is that for some class of algorithms it might be beneficial to be able to "drop on the floor" a bigger part of the graph altogether. ...
    (comp.lang.ada)
  • Elecsol batteries (again)
    ... Look at the graph at the bottom. ... D.O.D. means Depth of Discharge. ... cycles for various D.O.D.s between 50% and 100%. ... sense in that the deeper the discharge, the less life cycles each ...
    (uk.rec.waterways)
  • Re: Algorithm for breaking cycles in directed graph by edge removal
    ... It is clear to me that a DFS (depth first search) can find all cycles in a directed graph. ... DFS will label some edges as "BACK" edges; these back edges connect a node U to an ancestor node V in the traversal tree. ...
    (comp.theory)
  • Re: Algorithm for breaking cycles in directed graph by edge removal
    ... DFS will label some edges as "BACK" edges; ... Obviously, by removing the back edges, all cycles in the graph will be ... Maybe try constructing a dynamic programming algorithm to solve the ...
    (comp.theory)
  • Re: Graph to regions algorithm
    ... > My problem is that I need an algorithm witch will construct all regions ... The graph is convex and convex. ... To find cycles in a graph, you compute the "minimum spanning tree". ...
    (comp.graphics.algorithms)