@@ -43,20 +43,20 @@ private HashSet<MatchEdge<T>> getMaxBiPartiteMatching(IGraph<T> graph,
43
43
while ( freeVerticesOnRight . Count > 0 )
44
44
{
45
45
var visited = new HashSet < T > ( ) ;
46
- var paths = new HashSet < MatchEdge < T > > ( ) ;
46
+ var path = new HashSet < MatchEdge < T > > ( ) ;
47
47
48
48
foreach ( var vertex in freeVerticesOnRight )
49
49
{
50
- var path = dfs ( graph ,
50
+ var currentPath = dfs ( graph ,
51
51
leftToRightMatchEdges , rightToLeftMatchEdges , vertex , default , visited , true ) ;
52
52
53
- if ( path != null )
53
+ if ( currentPath != null )
54
54
{
55
- union ( paths , path ) ;
55
+ union ( path , currentPath ) ;
56
56
}
57
57
}
58
58
59
- xor ( matches , paths , leftToRightMatchEdges , rightToLeftMatchEdges ) ;
59
+ xor ( matches , path , leftToRightMatchEdges , rightToLeftMatchEdges ) ;
60
60
61
61
freeVerticesOnRight = bfs ( graph , partitions , leftToRightMatchEdges , rightToLeftMatchEdges ) ;
62
62
}
@@ -81,14 +81,14 @@ private List<T> bfs(IGraph<T> graph,
81
81
foreach ( var vertex in partitions [ 1 ] )
82
82
{
83
83
//if this left vertex is free
84
- if ( ! leftToRightMatchEdges . ContainsKey ( vertex ) )
84
+ if ( ! leftToRightMatchEdges . ContainsKey ( vertex ) && ! visited . Contains ( vertex ) )
85
85
{
86
86
queue . Enqueue ( vertex ) ;
87
- visited . Add ( vertex ) ;
88
-
87
+
89
88
while ( queue . Count > 0 )
90
89
{
91
90
var current = queue . Dequeue ( ) ;
91
+ visited . Add ( vertex ) ;
92
92
93
93
//unmatched edges left to right
94
94
foreach ( var leftToRightEdge in graph . GetVertex ( current ) . Edges )
0 commit comments