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

Added tests and examples #376

Merged
merged 8 commits into from
Dec 19, 2023

Conversation

ErikDervishi03
Copy link
Contributor

-this is a pull request for issues #58 and #3

  • i added 1) 2 test for dfs 2) a Prim example 3)a floyd warshall example.
  • @ZigRazor
  • Note: I ran the Floyd Warshall algorithm, and the result is not correct. I checked the test folder, and there isn't any test for the Floyd Warshall algorithm, so there isn't proof of its correctness. The error may be created by the example.

this is the output of floyd warshall example(all edges are undirected):

((Node: 2297668033614959926)) <----- |Edge: #1 W:4|-----> ((Node: 10159970873491820195))
((Node: 2297668033614959926)) <----- |Edge: #2 W:8|-----> ((Node: 905566266843721762))
((Node: 10159970873491820195)) <----- |Edge: #3 W:11|-----> ((Node: 905566266843721762))
((Node: 10159970873491820195)) <----- |Edge: #4 W:8|-----> ((Node: 4551451650890805270))
((Node: 4551451650890805270)) <----- |Edge: #5 W:2|-----> ((Node: 17899137375351314596))
((Node: 4551451650890805270)) <----- |Edge: #6 W:4|-----> ((Node: 7995238595416485409))
((Node: 4551451650890805270)) <----- |Edge: #7 W:7|-----> ((Node: 8248777770799913213))
((Node: 8248777770799913213)) <----- |Edge: #8 W:1|-----> ((Node: 8248777770799913213))
((Node: 8248777770799913213)) <----- |Edge: #9 W:9|-----> ((Node: 16215888864653804456))
((Node: 8248777770799913213)) <----- |Edge: #10 W:14|-----> ((Node: 7995238595416485409))
((Node: 16215888864653804456)) <----- |Edge: #11 W:10|-----> ((Node: 7995238595416485409))
((Node: 7995238595416485409)) <----- |Edge: #12 W:2|-----> ((Node: 3835993668518112351))
((Node: 3835993668518112351)) <----- |Edge: #13 W:6|-----> ((Node: 17899137375351314596))
((Node: 3835993668518112351)) <----- |Edge: #14 W:1|-----> ((Node: 905566266843721762))
((Node: 905566266843721762)) <----- |Edge: #15 W:7|-----> ((Node: 17899137375351314596))
floyd Warshall Result:
distance of: 5 3 = 1.79769e+308
distance of: 5 1 = 1.79769e+308
distance of: 5 6 = 2
distance of: 5 7 = 3
distance of: 5 2 = 1.79769e+308
distance of: 3 3 = 1
distance of: 3 6 = 16
distance of: 3 4 = 9
distance of: 3 7 = 17
distance of: 5 8 = 8
distance of: 3 8 = 22
distance of: 1 3 = 15
distance of: 1 1 = 0
distance of: 1 6 = 14
distance of: 6 2 = 1.79769e+308
distance of: 1 0 = 1.79769e+308
distance of: 0 4 = 28
distance of: 2 1 = 1.79769e+308
distance of: 0 0 = 0
distance of: 3 1 = 1.79769e+308
distance of: 0 8 = 14
distance of: 2 5 = 4
distance of: 0 1 = 4
distance of: 2 2 = 0
distance of: 5 5 = 0
distance of: 7 7 = 0
distance of: 4 7 = 13
distance of: 6 6 = 0
distance of: 0 7 = 8
distance of: 2 6 = 6
distance of: 0 2 = 12
distance of: 8 8 = 0
distance of: 8 2 = 1.79769e+308
distance of: 8 1 = 1.79769e+308
distance of: 8 0 = 1.79769e+308
distance of: 0 5 = 16
distance of: 8 5 = 1.79769e+308
distance of: 5 4 = 1.79769e+308
distance of: 5 0 = 1.79769e+308
distance of: 4 5 = 10
distance of: 2 8 = 2
distance of: 3 5 = 14
distance of: 0 3 = 19
distance of: 7 6 = 1.79769e+308
distance of: 8 4 = 1.79769e+308
distance of: 2 3 = 7
distance of: 8 6 = 1.79769e+308
distance of: 8 3 = 1.79769e+308
distance of: 2 7 = 7
distance of: 7 0 = 1.79769e+308
distance of: 4 8 = 18
distance of: 7 4 = 1.79769e+308
distance of: 3 2 = 1.79769e+308
distance of: 7 1 = 1.79769e+308
distance of: 7 3 = 1.79769e+308
distance of: 7 2 = 1.79769e+308
distance of: 2 0 = 1.79769e+308
distance of: 7 5 = 1.79769e+308
distance of: 4 0 = 1.79769e+308
distance of: 4 4 = 0
distance of: 1 7 = 11
distance of: 2 4 = 16
distance of: 4 1 = 1.79769e+308
distance of: 6 1 = 1.79769e+308
distance of: 4 3 = 1.79769e+308
distance of: 6 8 = 6
distance of: 7 8 = 7
distance of: 6 0 = 1.79769e+308
distance of: 4 2 = 1.79769e+308
distance of: 6 7 = 1
distance of: 0 6 = 18
distance of: 6 4 = 1.79769e+308
distance of: 8 7 = 1.79769e+308
distance of: 6 3 = 1.79769e+308
distance of: 3 0 = 1.79769e+308
distance of: 4 6 = 12
distance of: 6 5 = 1.79769e+308
distance of: 1 8 = 10
distance of: 1 5 = 12
distance of: 1 2 = 8
distance of: 1 4 = 24.

Since this is an undirected graph, if the distance between node A and node B is equal to x, then the distance between B and A should also be equal. However, you can see that the distance between 5 and 3 is 1.79769e+308 and the distance between 3 and 5 is 14.

it seems like i have passed a directed graph to the algorithm. is it a bug?

@ghost
Copy link

ghost commented Dec 16, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@ZigRazor
Copy link
Owner

please reproduce the problem in a test, and if present open an issue for this.
Thank you

@ZigRazor ZigRazor merged commit 20d818c into ZigRazor:master Dec 19, 2023
22 of 27 checks passed
@ErikDervishi03 ErikDervishi03 deleted the add_tests_and_examples branch December 20, 2023 13:30
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.

2 participants