Skip to content

Commit

Permalink
added more debug info for MIS (#26)
Browse files Browse the repository at this point in the history
* update

* update
  • Loading branch information
ArrogantGao authored Dec 4, 2024
1 parent a08f59e commit e16e7bf
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/OptimalBranchingCore/src/branch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Branch the given problem using the specified solver configuration.
The resulting value, which may have different type depending on the `result_type`.
"""
function branch_and_reduce(problem::AbstractProblem, config::BranchingStrategy, reducer::AbstractReducer, result_type)
@debug "Branching and reducing problem" problem
isempty(problem) && return zero(result_type)
# reduce the problem
rp, reducedvalue = reduce_problem(result_type, problem, reducer)
Expand Down
3 changes: 3 additions & 0 deletions lib/OptimalBranchingMIS/src/algorithms/xiao2013_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ function twin_filter!(g::SimpleGraph)
add_edge!(g,nv(g),left_neighbor)
end
end
@debug "Removing twin vertices, $(twin_pair[1]) $(twin_pair[2])"
rem_vertices!(g, vcat([twin_pair[1],twin_pair[2]],neighbor))

return true
Expand Down Expand Up @@ -130,6 +131,7 @@ function short_funnel_filter!(g::SimpleGraph)
isnothing(funnel_pair) && return false

a,b = funnel_pair
@debug "Removing short funnel vertices, $(a) $(b)"
N_a = neighbors(g, a)
N_b = neighbors(g, b)
for u in setdiff(N_a,vcat(N_b,[b])), v in setdiff(N_b,vcat(N_a,[a]))
Expand Down Expand Up @@ -164,6 +166,7 @@ function desk_filter!(g::SimpleGraph)
isnothing(desk_group) && return false

a,b,c,d = desk_group
@debug "Removing desk vertices, $(a) $(b) $(c) $(d)"
for u in setdiff(open_neighbors(g, [a,c]), closed_neighbors(g, [b,d])) # N(a, c) - N[b, d]
for v in setdiff(open_neighbors(g, [b,d]), closed_neighbors(g, [a,c])) # N(b, d) - N[a, c]
!has_edge(g,u,v) && add_edge!(g,u,v)
Expand Down
1 change: 1 addition & 0 deletions lib/OptimalBranchingMIS/src/graphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ function Graphs.neighbors(g::SimpleGraph, vs::Vector{Int})
end

function folding(g::SimpleGraph, v::Int)
@debug "Folding vertex $(v)"
@assert degree(g, v) == 2
a, b = neighbors(g, v)
if has_edge(g, a, b)
Expand Down
1 change: 1 addition & 0 deletions lib/OptimalBranchingMIS/src/reducer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function OptimalBranchingCore.reduce_problem(::Type{R}, p::MISProblem, ::XiaoRed

unconfined_vs = unconfined_vertices(g)
if length(unconfined_vs) != 0
@debug "Removing unconfined vertex $(unconfined_vs[1])"
rem_vertices!(g, [unconfined_vs[1]])
return MISProblem(g), R(0)
end
Expand Down
3 changes: 3 additions & 0 deletions lib/OptimalBranchingMIS/src/selector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function OptimalBranchingCore.select_variables(p::MISProblem, m::M, selector::Mi
novs_min = length(ovs)
end
end
@debug "Selecting vertices $(vs_min) by boundary"
return vs_min
end

Expand Down Expand Up @@ -60,6 +61,7 @@ function OptimalBranchingCore.select_variables(p::MISProblem, m::M, selector::Mi
for v in 1:nv(g)
if degree(g, v) high_degree_threshold
vs_min = neighbor_cover(g, v, high_degree_neighbor)[1]
@debug "Selecting vertices $(vs_min) by high degree, degree $(degree(g, v))"
return vs_min
end
end
Expand All @@ -72,5 +74,6 @@ function OptimalBranchingCore.select_variables(p::MISProblem, m::M, selector::Mi
novs_min = length(ovs)
end
end
@debug "Selecting vertices $(vs_min) by boundary"
return vs_min
end

0 comments on commit e16e7bf

Please sign in to comment.