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-27 18:38:26 +02:00
|
|
|
@test length(generate_options(g_ABAB).nodeFusions) == 10
|
2023-06-26 14:24:14 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2023-06-27 18:38:26 +02:00
|
|
|
while !isempty(options.nodeFusions)
|
|
|
|
fusion = options.nodeFusions[1]
|
|
|
|
|
|
|
|
@test typeof(fusion) <: NodeFusion
|
|
|
|
|
|
|
|
push_operation!(g, fusion)
|
2023-06-26 14:24:14 +02:00
|
|
|
|
|
|
|
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
|