[Cialug] Need An Algo Suggestion
Trent
devolver42 at gmail.com
Fri Oct 15 18:14:24 UTC 2021
This input data represents a directed graph. You can visualize it by
writing your numbers out on a whiteboard, then each of your pairs
represents an arrow from one number to another number.
You want to do a depth-first traversal of the graph (that's the algorithm
you're looking for). I'm not sure what language you're using, but if you
Google "depth first traversal directed graph " and the language you're
using, you should be in the ballpark of the answer you're looking for.
This might be a good starting point:
https://www.geeksforgeeks.org/iterative-depth-first-traversal/
Hope that helps!
Trent
On Thu, Oct 14, 2021 at 3:19 PM Todd Walton <tdwalton at gmail.com> wrote:
> I'm not a programmer. Not really. If I had a list of things like this:
>
> 1,2
> 2,3
> 2,4
> 3,6
>
> how would I map them so that I can see that 1 refers to 2, 2 refers to 3
> and 4, and 3 refers to 6, so:
>
> 1,2,3,6
> 1,2,4
> 2,3,6
> 2,4
> 3,6
>
> Like that? I want to build up those chains. Every chain has an end. There's
> no infinite loops. But some have multiple paths.
>
> I'm not sure how to do that, and I'm not sure what to call it for the
> purposes of DDGing it.
>
> --
> Todd
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> https://www.cialug.org/cgi-bin/mailman/listinfo/cialug
>
--
“We must learn to regard people less in the light of what they do or omit
to do, and more in the light of what they suffer.” - Dietrich Bonhoeffer
More information about the Cialug
mailing list