Skip to content

Commit da7880b

Browse files
authored
Merge pull request #1841 from Keno/kf/showstate
Show selected states in MatchedSystemStructure
2 parents 6d459f5 + e4b039f commit da7880b

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/bipartite_graph.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ end
204204
struct BipartiteAdjacencyList
205205
u::Union{Vector{Int}, Nothing}
206206
highligh_u::Union{Set{Int}, Nothing}
207-
match::Union{Int, Unassigned}
207+
match::Union{Int, Bool, Unassigned}
208208
end
209209
function BipartiteAdjacencyList(u::Union{Vector{Int}, Nothing})
210210
BipartiteAdjacencyList(u, nothing, unassigned)
@@ -225,16 +225,21 @@ function Base.show(io::IO, hi::HighlightInt)
225225
end
226226

227227
function Base.show(io::IO, l::BipartiteAdjacencyList)
228+
if l.match === true
229+
printstyled(io, "", color = :light_blue, bold = true)
230+
end
228231
if l.u === nothing
229232
printstyled(io, '', color = :light_black)
230233
elseif isempty(l.u)
231234
printstyled(io, '', color = :light_black)
232235
elseif l.highligh_u === nothing
233236
print(io, l.u)
234237
else
238+
match = l.match
239+
isa(match, Bool) && (match = unassigned)
235240
function choose_color(i)
236-
i in l.highligh_u ? (i == l.match ? :light_yellow : :green) :
237-
(i == l.match ? :yellow : nothing)
241+
i in l.highligh_u ? (i == match ? :light_yellow : :green) :
242+
(i == match ? :yellow : nothing)
238243
end
239244
if !isempty(setdiff(l.highligh_u, l.u))
240245
# Only for debugging, shouldn't happen in practice

src/systems/systemstructure.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,15 +439,17 @@ function Base.getindex(bgpm::SystemStructurePrintMatrix, i::Integer, j::Integer)
439439
(i - 1 <= length(invview(bgpm.var_eq_matching))) ?
440440
invview(bgpm.var_eq_matching)[i - 1] : unassigned)
441441
elseif j == 5
442+
match = unassigned
443+
if bgpm.var_eq_matching !== nothing && i - 1 <= length(bgpm.var_eq_matching)
444+
match = bgpm.var_eq_matching[i - 1]
445+
isa(match, Union{Int, Unassigned}) || (match = true) # Selected State
446+
end
442447
return BipartiteAdjacencyList(i - 1 <= ndsts(bgpm.bpg) ?
443448
𝑑neighbors(bgpm.bpg, i - 1) : nothing,
444449
bgpm.highlight_graph !== nothing &&
445450
i - 1 <= ndsts(bgpm.highlight_graph) ?
446451
Set(𝑑neighbors(bgpm.highlight_graph, i - 1)) :
447-
nothing,
448-
bgpm.var_eq_matching !== nothing &&
449-
(i - 1 <= length(bgpm.var_eq_matching)) ?
450-
bgpm.var_eq_matching[i - 1] : unassigned)
452+
nothing, match)
451453
else
452454
@assert false
453455
end

0 commit comments

Comments
 (0)