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
WIP: BipartiteGraph and Hopcroft-Karp algorithm in C++ #1481
base: master
Are you sure you want to change the base?
Conversation
matchpygen/bipartite.h
Outdated
|
||
//Node = Tuple[int, Union[TLeft, TRight]] | ||
// typedef tuple<int, variant<TLeft, TRight>> Node; ??? | ||
typedef tuple<int, TItem> Node; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TItem
is either TLeft
or TRight
. We could have typedef variant<TLeft, TRight> TItem
, but this is probably only supported in C++17. As an alternative, two separate fields could be used. This latter alternative would probably some quantity of code to be reviewed.
Try to use the formatting that our clang-format configuration enforces. The biggest one is to use 4 spaces, instead of tabs. |
@isuruf this is interesting. It looks like @Upabjojr applied the patch from our bot, but then the bot complained again. In particular, the bot first suggested the change: -//(Generic[TLeft, TRight, TEdgeValue], MutableMapping[Tuple[TLeft, TRight], TEdgeValue])
+//(Generic[TLeft, TRight, TEdgeValue], MutableMapping[Tuple[TLeft, TRight],
+//TEdgeValue]) and after @Upabjojr applied it, our bot now suggests this one instead: --- a/matchpygen/bipartite.h
+++ b/matchpygen/bipartite.h
@@ -22,7 +22,7 @@ const int RIGHT = 1;
typedef map<tuple<int, int>, tuple<int, int>> Matching;
//(Generic[TLeft, TRight, TEdgeValue], MutableMapping[Tuple[TLeft, TRight],
-//TEdgeValue])
+// TEdgeValue])
/*
* A bipartite graph representation.
*/ So the question is why didn't the bot suggest the correct (final) change in the first place? |
@Upabjojr, thanks for your work on this. I have two questions on the design decisions.
|
It's more generic, you can generalize the class usages to more types. I am opening PRs to SymEngine, but that's only a temporary measure. We may decide to put the code in a separate project.
I suppose you mean the _graph field, as the graph is only one. Right now, I am just translating the code written in Python in MatchPy. The usage of two separate class variables is an issue in MatchPy. See HPAC/matchpy#43 |
Added Takeaki Uno's algorithm. New code has not yet been tested. |
This is not supposed to be merged. These are algorithms needed for the commutative matcher of MatchPy. We will need these algorithms to port RUBI into C++.
Class
BipartiteGraph
was translated from its Python implementation at MatchPyThe Hopcroft Karp algorithm is my implementation, which solves the issue of relying on the GPL'd Python library (dependency of MatchPy).