I find it difficult to find tree-like data structures for use in ruby. Are there any known ones that I can look at? My requirements are simple. I want to create a tree (or maybe a graph), and find the distance between some nodes. For example, I may have a tree / graph as shown below.
A / \ B-----C / \ \ DEF
I want to find the distances between the root of node (A) and all other nodes. Thus, the distance between (A, B) should be 1, between (A, E) equal to 2, etc. Even if from node (A) you can go to (C) via (A, B, C), the length should only be 1, since there is a direct path from (A, C).
Is there a tree / graph that I can use in ruby ββfor this?
source share