Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for non-loop? #10

Closed
KesWalker opened this issue Nov 15, 2023 · 3 comments
Closed

Option for non-loop? #10

KesWalker opened this issue Nov 15, 2023 · 3 comments

Comments

@KesWalker
Copy link

Is it possible to get the shortest path without having to return to the first point?

One where the last point is the furthest away so the salesman doesn't have to return all the way back to the starting point?

@lovasoa
Copy link
Owner

lovasoa commented Nov 15, 2023

Hello ! No, it's not possible with the current implementation.

@lovasoa lovasoa closed this as completed Nov 15, 2023
@KesWalker
Copy link
Author

Does the following not acheive something similar?

Path.prototype.randomPos = function () {
if (this.roundTrip) {
    return 1 + Math.floor(Math.random() * (this.points.length - 1));
} else {
    return Math.floor(Math.random() * this.points.length);
}
};

@lovasoa
Copy link
Owner

lovasoa commented Nov 15, 2023

I don't think so. But if you open a clean pull request with good code and tests, I'll merge it 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants