Skip to content

Commit

Permalink
Merge pull request #27 from oscarhiggott/parallel-edge-error-messages
Browse files Browse the repository at this point in the history
Improve error message for parallel edges. Fixes #26.
  • Loading branch information
oscarhiggott committed Mar 9, 2022
2 parents 1b85843 + 112b829 commit 92a09ff
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pymatching/matching_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ void MatchingGraph::AddEdge(
int num_nodes = GetNumNodes();
bool nodes_in_graph = (n1 < num_nodes) && (n2 < num_nodes);
if (nodes_in_graph && boost::edge(n1, n2, matching_graph).second){
throw std::invalid_argument("This edge already exists in the graph. "
"Parallel edges are not supported.");
throw std::invalid_argument("Edge (" + std::to_string(n1) + "," + std::to_string(n2) +
") already exists in the matching graph, but "
"parallel edges are not supported. Consider merging "
"parallel edges into a single edge instead.");
}
if (std::signbit(weight)){
HandleNewNegativeWeightEdge(node1, node2, weight, fault_ids);
Expand Down

0 comments on commit 92a09ff

Please sign in to comment.