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

bug on a floyd warshall test #378

Closed
ErikDervishi03 opened this issue Dec 18, 2023 · 0 comments · Fixed by #380
Closed

bug on a floyd warshall test #378

ErikDervishi03 opened this issue Dec 18, 2023 · 0 comments · Fixed by #380

Comments

@ErikDervishi03
Copy link
Contributor

Bug description
I created a Floyd-Warshall test, and it is failing.

To reproduce
Create a Floyd-Warshall test file and add the following test case:

TEST(FloydWarshallTest, test_2) {
  CXXGraph::Node<int> node0("0", 0);
  CXXGraph::Node<int> node1("1", 1);

  CXXGraph::UndirectedWeightedEdge<int> edge1(1, node0, node1, 1);

  CXXGraph::T_EdgeSet<int> edgeSet;
  edgeSet.insert(make_shared<CXXGraph::UndirectedWeightedEdge<int>>(edge1));

  CXXGraph::Graph<int> graph(edgeSet);
  CXXGraph::FWResult res = graph.floydWarshall();

  auto distance_0_1 = res.result.find(std::make_pair("0", "1"));
  auto distance_1_0 = res.result.find(std::make_pair("1", "0"));

  ASSERT_TRUE(res.success);
  ASSERT_FALSE(res.negativeCycle);
  ASSERT_EQ(res.errorMessage, "");
  ASSERT_EQ(distance_0_1->second, distance_1_0->second);
} 

Expected behavior
The test should pass without any failures.

Screenshots

Failure
Expected equality of these values:
  distance_0_1->second
    Which is: 1
  distance_1_0->second
    Which is: 1.7976931348623157e+308
...
[  FAILED  ] 1 test, listed below:
[  FAILED  ] FloydWarshallTest.test_2

 1 FAILED TEST

Additional context
-Since edge 1 is an UndirectedWeightedEdge the distance from node 1 and 0 and the distance from node 1 and node 0 should be equal if the floyd warshall algorithm is correct.
-This issue was created after considering this suggestion: : #376 (comment)

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 a pull request may close this issue.

1 participant