http://www.perlmonks.org?node_id=904729


in reply to Re^11: Finding All Paths From a Graph From a Given Source and End Node
in thread Finding All Paths From a Graph From a Given Source and End Node

Hi,

Even though this thread is about 6 months old I find it really very useful, as I am currently working on a similar project and have struggled with it, being quite a young programmer.I have read through it all and feel that I might be able to get the help that I need.

I have a network containing about 2500 edges (directed) and I am looking at being able to work out all the routes downstream from a given beginning node. The difference from neversaint's problem is that both beginning and end nodes are supplied in his.My initial concerns was that it'd result in very large output that may not be manageable but considering that it is currently not a very large network and that I really need to identify all the routes i am willing to give it a try.

I will be happy to have your inputs and thoughts

Thank you very much in advance

  • Comment on Re^12: Finding All Paths From a Graph From a Given Source and End Node

Replies are listed 'Best First'.
Re^13: Finding All Paths From a Graph From a Given Source and End Node
by BrowserUk (Patriarch) on May 13, 2011 at 21:32 UTC
    I have a network containing about 2500 edges (directed) and I am looking at being able to work out all the routes downstream from a given beginning node.

    Hm. What is your terminating condition?

    A directed graph can contain loops:

    a->b->c ^ | | v e<-d

    If your starting node is (a), when do you decide you've reach the (an) end?

    Every time around the b->c->d->e->b loop, could be seen as another route. The only logical basis I can see for breaking that impasse is a rule along the lines of "Stop when there is no possibility of reaching a so far unvisited node. And that could be quite difficult to program efficiently.

    As so often, more info required?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Hi, BrowserUK,

      Sorry for the delayed reply. Have been inundated with work these two weeks. I just got some breathing space.

      To the question of terminating condition: The network is built from biodegradation reactions where, in A->B, B is the result of some reaction from A and the edge represents enzymes catalysing such a reaction. The source of the information is also such that most of the reaction paths have logical end points.

      The terminating situation will be when the path ends and there is no possibility of futher elongation along the path of interest.

      Example: J->K ^ | A->B->C->D->E ^ | | v H<-G

      A->B->C->D->E or A->B->C->D->G->H->C->J->K, would be correctly admissible in the resulting path.

      The edge between C and D should not be allowed again (as in that loop) seeing that in real life that enzyme would already be in the system and need not be captured again. However C as a node could be captured again (eg C->J). The important factor in the resulting pathways should be the edges. An earlier captured 'node-edge-node' should not be captured again, until the the path logically ends (without a possibility of further elongation).

      I hope the information supplied is sufficiently clear and helpful.

      Thank you so very much.

        The network is built from biodegradation reactions where, in A->B, B is the result of some reaction from A and the edge represents enzymes catalysing such a reaction. ...

        Hm. That suggests that having transitioned from the A state to the B state, you cannot go backwards to the A state.

        But then you have two sentences that have an overriding termination (or perhaps extension) criteria:

        The terminating situation will be when the path ends and there is no possibility of futher elongation along the path of interest. ...

        An earlier captured 'node-edge-node' should not be captured again, until the the path logically ends (without a possibility of further elongation).

        And in your example, having transitioned from c-d, the reaction(s) can find their way back to the c state; and then leave via a different route.

        Your path:A->B->C->D->G->H->C->J->K

        So my question is, if the reaction can go from c-d once; and can find its way back to c; why can it not transition c-d a second time?

        Which would make the path a-b-c-d-g-h-c-d-e an elongation of the path you've identified as legitimate: A->B->C->D->E

        Thinking, I hope logically, about a subject I know next to nothing about, I considered the possibility that whatever enzymes are in the original mix, when the C state occures it preferentially reacts with whichever enzyme(s) are required to transition to state D.

        And in doing so, depletes the mix of that(those) enzymes. Which means that when the mix arrives at the C state a second time, those enzymes are no longer present so it can now react with other enzymes that cause it to transition to state J.

        Is that a viable, even if technically inaccurate, model of what goes on?

        If so, I think an efficient solution is possible.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.