Skip to content

feat: add kruskal algorithm #137

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

Merged
merged 2 commits into from
Jun 16, 2023
Merged

Conversation

caojoshua
Copy link
Contributor

add well-known kruskal's algorithm

Is it plagiarism to use test cases from other TheAlgorithms repos? I got testcases from https://github.com/TheAlgorithms/Rust/blob/master/src/graph/minimum_spanning_tree.rs to avoid having to come up with interesting graph cases myself. If this is a problem, I can rewrite stuff from scratch.

@appgurueu
Copy link
Contributor

The Rust repo is licensed under the MIT license. This means you have to attribute it properly (and state the license), unless you wrote the tests on the Rust repo yourself (then you are free to just copy them).

Copy link
Contributor

@appgurueu appgurueu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation of Kruskal's algorithm looks correct to me. Note that it won't be restricted to Minimum Spanning Trees; if the input graph is disconnected, it will compute a Minimum Spanning Forest.

The tests still need attribution. You could also directly write the edges in the array literals rather than verbosely pushing them.

@caojoshua
Copy link
Contributor Author

The Rust repo is licensed under the MIT license. This means you have to attribute it properly (and state the license), unless you wrote the tests on the Rust repo yourself (then you are free to just copy them).

I believe this is fine from a licensing perspective. Attribution means that a copy of the license is included with the software. Both the Typescript and Rust repos have the MIT license with The Algorithms copyright holder, covering the attribution requirement (different years though, not sure if that is a concern).

My question is more about the definition of plagiarism according to The Algorithms contributing guidelines. Its not simple to directly use the Oxford definition of plagiarism for example

the practice of taking someone else's work or ideas and passing them off as one's own.

Most implementations in the Algorithms are re-implementations of well-known algorithms, and in most cases authors probably looked at reference implementations or reading materials, yet we don't consider it plagiarism. The test cases I provided can be looked at as a re-implementation of test cases I saw elsewhere within The Algorithms, but I am not sure if that falls under the scope of plagiarism.

@caojoshua
Copy link
Contributor Author

Note that it won't be restricted to Minimum Spanning Trees; if the input graph is disconnected, it will compute a Minimum Spanning Forest.

Oh yeah, this is unintentional but welcome. Let me change comments and add some test cases.

@appgurueu
Copy link
Contributor

The Rust repo is licensed under the MIT license. This means you have to attribute it properly (and state the license), unless you wrote the tests on the Rust repo yourself (then you are free to just copy them).

I believe this is fine from a licensing perspective. Attribution means that a copy of the license is included with the software. Both the Typescript and Rust repos have the MIT license with The Algorithms copyright holder, covering the attribution requirement (different years though, not sure if that is a concern).

Honestly the "The Algorithms" copyright holder is questionable; I don't think that "The Algorithms" are a registered organization or the like. I would have expect copyright holders like "the Rust repo contributors" and "the JS repo contributors" (which can be found in the files / commit history) rather than "the Algorithms", wrongly implying that the same people had been working on all these repos.

Still, I'd consider it good practice to attribute the source of the tests; a single comment containing a permalink should work. This is also helpful in case someone happens to find an issue with the tests or the like.

Most implementations in the Algorithms are re-implementations of well-known algorithms, and in most cases authors probably looked at reference implementations or reading materials, yet we don't consider it plagiarism. The test cases I provided can be looked at as a re-implementation of test cases I saw elsewhere within The Algorithms, but I am not sure if that falls under the scope of plagiarism.

To be sure I don't plagiarize reference implementations, I usually don't look at them (rather, I just understand the algorithm), and implement algorithms from memory; I avoid porting code side-by-side. A reimplementation is not necessarily free from licensing issues by pure virtue of being a reimplementation.

We're not passing the algorithms off as our own; we're merely claiming that the implementations are our own.

@caojoshua
Copy link
Contributor Author

OK yeah, I think its easiest to rewrite tests. Not a huge fan of permalinks in code. I still think its an interesting discussion, but that can take place else where.

@raklaptudirm raklaptudirm merged commit 55a01f2 into TheAlgorithms:master Jun 16, 2023
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

Successfully merging this pull request may close these issues.

3 participants