metagraphoptimization.jl/test/known_graphs.jl

55 lines
1.3 KiB
Julia
Raw Normal View History

2023-06-22 17:24:35 +02:00
using MetagraphOptimization
using Test
function test_known_graphs()
g_ABAB = import_txt(joinpath(@__DIR__, "..", "examples", "AB->AB.txt"))
props = graph_properties(g_ABAB)
@test length(g_ABAB.nodes) == 34
@test props.compute_effort == 185
@test props.data == 102
2023-06-26 14:24:14 +02:00
@test length(generate_options(g_ABAB).fusions) == 10
test_node_fusion(g_ABAB)
g_ABAB3 = import_txt(joinpath(@__DIR__, "..", "examples", "AB->ABBB.txt"))
props = graph_properties(g_ABAB3)
@test length(g_ABAB3.nodes) == 280
@test props.compute_effort == 2007
@test props.data == 828
test_node_fusion(g_ABAB3)
end
function test_node_fusion(g)
props = graph_properties(g)
options = generate_options(g)
nodes_number = length(g.nodes)
data = props.data
compute_effort = props.compute_effort
while length(options.fusions) != 0
fusion = options.fusions[1]
n = node_fusion(g, fusion[1], fusion[2], fusion[3])
@test typeof(n.task) <: FusedComputeTask
@test length(g.nodes) == nodes_number - 2
props = graph_properties(g)
@test props.data < data
@test props.compute_effort == compute_effort
nodes_number = length(g.nodes)
data = props.data
compute_effort = props.compute_effort
options = generate_options(g)
end
print(g)
2023-06-22 17:24:35 +02:00
end