in reply to find shortest path for each query from a CSV file
I'd start by storing the data in a hash of hashes, but perhaps hash of arrays will be needed if multiple children nodes are possible.
There might be some useful tools in List::Utils, but if not, I'd probably store a sister element with depth as I walked through the tree (more efficient to build that whilst assembling the master tree, I should think).
From there it is likely to be straight subtraction of the depth values and select the smallest one(s). Would likely expect a tree walk for that part.
Probably build a reverse path hash on the way in, report on it on the way out.
For more details, post some code and show what isn't working as expected.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: find shortest path for each query from a CSV file
by zing (Beadle) on Nov 22, 2013 at 09:15 UTC |