Skip to content

Commit

Permalink
Fixed mincut tests, to allow for degenrate solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyT1994 committed Oct 24, 2023
1 parent 7c2571f commit 4b87693
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions test/test_namedgraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -390,17 +390,16 @@ end
g = NamedGraph(path_graph(4), ["A", "B", "C", "D"])

part1, part2, flow = GraphsFlows.mincut(g, "A", "D")
@test issetequal(part1, ["A"])
@test issetequal(part2, ["B", "C", "D"])
@test "A" part1
@test "D" part2
@test flow == 1

part1, part2 = mincut_partitions(g, "A", "D")
@test issetequal(part1, ["A"])
@test issetequal(part2, ["B", "C", "D"])
@test "A" part1
@test "D" part2

part1, part2 = mincut_partitions(g)
@test issetequal(part1, ["B", "C", "D"])
@test issetequal(part2, ["A"])
@test issetequal(vcat(part1, part2), vertices(g))

weights_dict = Dict{Tuple{String,String},Float64}()
weights_dict["A", "B"] = 3
Expand All @@ -411,17 +410,17 @@ end

for weights in (weights_dict, weights_dictionary)
part1, part2, flow = GraphsFlows.mincut(g, "A", "D", weights)
@test issetequal(part1, ["A", "B"])
@test issetequal(part2, ["C", "D"])
@test issetequal(part1, ["A", "B"]) || issetequal(part1, ["C", "D"])
@test issetequal(vcat(part1, part2), vertices(g))
@test flow == 2

part1, part2 = mincut_partitions(g, "A", "D", weights)
@test issetequal(part1, ["A", "B"])
@test issetequal(part2, ["C", "D"])
@test issetequal(part1, ["A", "B"]) || issetequal(part1, ["C", "D"])
@test issetequal(vcat(part1, part2), vertices(g))

part1, part2 = mincut_partitions(g, weights)
@test issetequal(part1, ["C", "D"])
@test issetequal(part2, ["A", "B"])
@test issetequal(part1, ["A", "B"]) || issetequal(part1, ["C", "D"])
@test issetequal(vcat(part1, part2), vertices(g))
end
end
@testset "dijkstra" begin
Expand Down Expand Up @@ -558,7 +557,7 @@ end
add_edge!(g, "E" => "G")
t = topological_sort_by_dfs(g)
for e in edges(g)
@test findfirst(x -> x == src(e), t) < findfirst(x -> x == dst(e), t)
@test findfirst(x -> x == src(e), t) < findfirst(x -> x == dst(e), t)
end
end
end

0 comments on commit 4b87693

Please sign in to comment.