Shortest polyline between points

Hi, just a quick question, just wondering if there is a way to find the shortest polyline between a list of points.


In Rhino? Grasshopper? C#? Python? By hand?

You didn’t pick a category for your question, so it’s not clear what the context is.


1 Like

haha sorry i forgot, using grasshopper. i was not thinking of many points (eg.10) so i was wondering if its possible to let galapagos change the order of points and minimise the length as fitness.

thanks :slight_smile:

old but might work or at least get you pointed in the right direction.

Rhino does have some methods for determining most-likely point order, but Grasshopper doesn’t expose any of it. To be honest I can’t even find anything for it in the RhinoCommon api, so it might not be exposed at all.

hmm okay. i am still exploring. is there a method to manually assign each of the 10 points an index in a list using a number slider such that galapagos can control it?


i have a follow up question, is it possible to generate a list of numbers like this just by telling it how many items there are?



Yes it’s called series component

hi thanks for the reply,
but that is to generate a list of running numbers right?

what if i want a list with the first item as (1) and second item as (1,2) etc. to the nth item (1,2…n)?

the starting number can either be 0 or 1, doesnt matter to me, i am just wondering how to generate a list like that.

thanks so much!

AH great thanks so much. was thinking of using 2 series components but i didnt think of that. thanks again

If your set is small (like ten or smaller) you could just brute force it and generate all permutations of the point set. This grows super expensive fast though, but will for certain give you the smallest path that connects all the points. Here’s a quick GHPython implementation: (5.2 KB)

You can look up the travelling salesman problem on the old Grasshopper3D forum and on Google for more directed algorithms/heuristics that’ll be more performant on larger sets.