13,051,413 members (51,642 online)
Rate this:
See more:
Hello,

I have list of points
mydots[][points] = { {"x,y,z"}} // 2000 dots

what is the best and fastest way to connect nearest dots in same line?

I hope you will understand?

green line are good , red one not.

photo[^]
Posted 14-Mar-13 17:11pm
Sergey Alexandrovich Kryukov 14-Mar-13 23:15pm

Yes, it's clear. What have you tried so far? The algorithm is pretty simple, but writing the code would need some time, and optimization of it is less trivial...
—SA
125Azazelo 14-Mar-13 23:53pm

I have try to search by range of dots to see are they in range but some time i get false positive result , i was try to check is a point in line but also get some unexpected dots.
so i interested just theoretic or pseudo code what be the fastest way, or some prepossessing to minimal run time use of resource.
Matthew Faithfull 15-Mar-13 3:19am

It sounds like you're working on something like The Travelling Salesman Problem, http://en.wikipedia.org/wiki/Travelling_salesman_problem. If so this page has lots of info on possible solutions. If you find a better one you will be famous and possibly very rich :-)
Ian A Davidson 15-Mar-13 7:01am

Very interesting. Thanks for this link. This should be listed as the answer to this question!
Matthew Faithfull 15-Mar-13 11:33am

OK as we haven't heard further from the author in 12 hours and no one else has proffered a solution I'll repost my comment as a solution. It sounds like the OP is wanting a TSP variant or a simplified but related algorithm rather than a striaght TSP but without a reponse I can't confirm this.
125Azazelo 4-Apr-13 21:58pm

Is just some small project but i not use any of this listed systems if i manage to be bug free i will share it.it take whit bugs(0.2sec for 2000 dots) and ~20% false hits.Thank you for this and info about be rich :) .

Rate this:

## Solution 1

It sounds like you're working on something like The Travelling Salesman Problem, http://en.wikipedia.org/wiki/Travelling_salesman_problem. If so this page has lots of info on possible solutions. If you find a better one you will be famous and possibly very rich :-)

I've reposted my comment as no other solution has been posted.
nv3 15-Mar-13 12:27pm

Got my 5, Matthew.
H.Brydon 16-Mar-13 0:36am

+5 from me...
J.Surjith Kumar 16-Mar-13 8:00am

my 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 OriginalGriff 453 Graeme_Grant 151 Sheila Pontes 110 Afzaal Ahmad Zeeshan 110 ppolymorphe 85
 OriginalGriff 5,431 RickZeeland 1,944 ppolymorphe 1,838 F-ES Sitecore 1,606 Dave Kreskowiak 1,409

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 15 Mar 2013