Skip to content

Commit 9581dce

Browse files
committed
Fix consistency checks
1 parent 41cc6ea commit 9581dce

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/bipartite_graph.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,18 @@ end
6868

6969
function complete(m::Matching{U}) where {U}
7070
m.inv_match !== nothing && return m
71-
inv_match = Union{U, Int}[unassigned for _ = 1:length(m.match)]
71+
N = length(m.match)
72+
inv_match = Union{U, Int}[unassigned for _ = 1:N]
7273
for (i, eq) in enumerate(m.match)
7374
isa(eq, Int) || continue
74-
inv_match[eq] = i
75+
if eq <= N
76+
inv_match[eq] = i
77+
else # this only happens when the system is imbalanced
78+
for k in N+1:eq-1
79+
push!(inv_match, unassigned)
80+
end
81+
push!(inv_match, i)
82+
end
7583
end
7684
return Matching{U}(collect(m.match), inv_match)
7785
end

src/structural_transformation/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function check_consistency(state::TearingState)
5959
iseqs = n_highest_vars < neqs
6060
if iseqs
6161
eq_var_matching = invview(complete(var_eq_matching)) # extra equations
62-
bad_idxs = findall(isnothing, @view eq_var_matching[1:nsrcs(graph)])
62+
bad_idxs = findall(isequal(unassigned), @view eq_var_matching[1:nsrcs(graph)])
6363
else
6464
bad_idxs = findall(isequal(unassigned), var_eq_matching)
6565
end

0 commit comments

Comments
 (0)