Skip to content

Commit

Permalink
Fix for Edge equality operator is incorrect ZigRazor#333
Browse files Browse the repository at this point in the history
  • Loading branch information
nrkramer committed Jul 28, 2023
1 parent ca468b0 commit 1b4ed69
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
1 change: 1 addition & 0 deletions include/Graph/Graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <cstring>
#include <deque>
#include <fstream>
#include <sstream>
#include <functional>
#include <iostream>
#include <limits>
Expand Down
2 changes: 1 addition & 1 deletion include/Utility/PointerHash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ template <typename T>
bool operator==(shared<const Edge<T>> p1, shared<const Edge<T>> p2) {
return p1->getNodePair().first->getUserId() ==
p2->getNodePair().first->getUserId() &&
p2->getNodePair().second->getUserId() ==
p1->getNodePair().second->getUserId() ==
p2->getNodePair().second->getUserId();
}
} // namespace CXXGraph
Expand Down
27 changes: 14 additions & 13 deletions test/GraphTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ TEST(GraphTest, DirectedEdgeCycle_1) {
CXXGraph::DirectedEdge<int> edge2(1, node2, node1);
CXXGraph::DirectedEdge<int> edge3(2, node3, node1);

CXXGraph::Graph<int> graph;

graph.addEdge(&edge1);
graph.addEdge(&edge2);
graph.addEdge(&edge3);
Expand Down Expand Up @@ -217,8 +219,6 @@ TEST(GraphTest, DirectedEdge_hashequality) {
CXXGraph::DirectedEdge<int> edge10(10, node6, node2);
CXXGraph::DirectedEdge<int> edge11(11, node7, node2);

CXXGraph::Graph<int> graph;

CXXGraph::T_EdgeSet<int> edges;
auto addEdge = [&](CXXGraph::DirectedEdge<int>& edge)
{
Expand All @@ -233,18 +233,19 @@ TEST(GraphTest, DirectedEdge_hashequality) {
}
};

addEdge(&edge1);
addEdge(&edge2);
addEdge(&edge3);
addEdge(&edge4);
addEdge(&edge5);
addEdge(&edge6);
addEdge(&edge7);
addEdge(&edge8);
addEdge(&edge9);
addEdge(&edge10);
addEdge(&edge11);
addEdge(edge1);
addEdge(edge2);
addEdge(edge3);
addEdge(edge4);
addEdge(edge5);
addEdge(edge6);
addEdge(edge7);
addEdge(edge8);
addEdge(edge9);
addEdge(edge10);
addEdge(edge11);

CXXGraph::Graph<int> graph;
graph.setEdgeSet(edges);

// Check that all of the edges have been added to the graph
Expand Down

0 comments on commit 1b4ed69

Please sign in to comment.