Question

Determine every possible sequence of connecting lines


Badge +1

Hi,

I have a number of lines that join each other to create a 'web' like network. I need to find out every single unique combination of line segments that join together.

Does anyone have any ideas on how I would go about this?

Thanks,


5 replies

Badge +22

Personally I would use a TopolgyBuilder followed by a Depth-First-Search python implementation.

 

See https://en.wikipedia.org/wiki/Depth-first_search for a bit of theory and http://eddmann.com/posts/depth-first-search-and-breadth-first-search-in-python/ for a basic python implementation.
Badge +22

Personally I would use a TopolgyBuilder followed by a Depth-First-Search python implementation.

 

See https://en.wikipedia.org/wiki/Depth-first_search for a bit of theory and http://eddmann.com/posts/depth-first-search-and-breadth-first-search-in-python/ for a basic python implementation.

For a pure FME approach I suspect a lot of featureMergers and list exploders

Badge +5

OK, here's my quick thoughts. I'd go with a LineJoiner and test to see if it returns just one feature, or multiple features. If it is multiple features then the lines can't be joined together.

I have an example workspace that you can download from here: https://www.dropbox.com/s/xt0fmvdyfmeschf/Connect...

Notice how the group-by option is set up to differentiate between different groups (in the LineJoiner, Counter, and StatisticsCalculator). Basically it joins all lines in a group together, and counts how many features that results in. If there is just 1 feature for that group, then the lines must be a joinable combination.

So, what you would need to do here is add your data as a source, then create every unique combination of lines (where I've used a Creator and AttributeCreator). I'm thinking a Counter and loop of some sort. In short: my workspace is a way of checking the groups for connectivity, but your part will be to create those groups to be checked.

Be sure to give each group of lines a unique ID to use in the group by options.

Hope this is useful

Mark

Badge +3

i think he has a tree or some other structured web. He wants to tree walk it and determine all routes to its endnodes.

Often done using recursive algoritm's.

Check the tcl forum there are different ones.

I found one running all directories to files (the end nodes of the branches)

Userlevel 2
Badge +17

This is a prototype that finds every set of connectable lines by a fixed number of segments, used the ListSubsetEnumerator from the FME Hub: enumerate-connectable-k-lines.fmw (FME 2016.1)

It works, but is not efficient....

Reply