2023-08-29 12:57:46 +02:00
|
|
|
"""
|
2023-08-28 13:32:22 +02:00
|
|
|
get_properties(graph::DAG)
|
2023-08-29 12:57:46 +02:00
|
|
|
|
2023-08-28 13:32:22 +02:00
|
|
|
Return the graph's [`GraphProperties`](@ref).
|
2023-08-29 12:57:46 +02:00
|
|
|
"""
|
2023-08-28 13:32:22 +02:00
|
|
|
function get_properties(graph::DAG)
|
2023-08-25 10:48:22 +02:00
|
|
|
# make sure the graph is fully generated
|
|
|
|
apply_all!(graph)
|
2023-08-24 15:11:54 +02:00
|
|
|
|
2024-02-06 10:58:29 +01:00
|
|
|
# TODO: tests stop working without the if condition, which means there is probably a bug in the lazy evaluation and in the tests
|
|
|
|
if (graph.properties.computeEffort <= 0.0)
|
2023-08-28 13:32:22 +02:00
|
|
|
graph.properties = GraphProperties(graph)
|
2023-08-25 10:48:22 +02:00
|
|
|
end
|
2023-08-24 15:11:54 +02:00
|
|
|
|
2023-08-28 13:32:22 +02:00
|
|
|
return graph.properties
|
2023-08-24 15:11:54 +02:00
|
|
|
end
|
|
|
|
|
2023-08-29 12:57:46 +02:00
|
|
|
"""
|
|
|
|
get_exit_node(graph::DAG)
|
|
|
|
|
|
|
|
Return the graph's exit node. This assumes the graph only has a single exit node. If the graph has multiple exit nodes, the one encountered first will be returned.
|
|
|
|
"""
|
2023-08-24 15:11:54 +02:00
|
|
|
function get_exit_node(graph::DAG)
|
2023-08-25 10:48:22 +02:00
|
|
|
for node in graph.nodes
|
|
|
|
if (is_exit_node(node))
|
|
|
|
return node
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@assert false "The given graph has no exit node! It is either empty or not acyclic!"
|
2023-08-24 15:11:54 +02:00
|
|
|
end
|
2023-08-31 18:24:48 +02:00
|
|
|
|
|
|
|
"""
|
|
|
|
get_entry_nodes(graph::DAG)
|
|
|
|
|
|
|
|
Return a vector of the graph's entry nodes.
|
|
|
|
"""
|
|
|
|
function get_entry_nodes(graph::DAG)
|
2023-10-12 17:51:03 +02:00
|
|
|
apply_all!(graph)
|
2023-08-31 18:24:48 +02:00
|
|
|
result = Vector{Node}()
|
|
|
|
for node in graph.nodes
|
|
|
|
if (is_entry_node(node))
|
|
|
|
push!(result, node)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return result
|
|
|
|
end
|
2023-11-22 13:51:54 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
operation_stack_length(graph::DAG)
|
|
|
|
|
|
|
|
Return the number of operations applied to the graph.
|
|
|
|
"""
|
|
|
|
function operation_stack_length(graph::DAG)
|
|
|
|
return length(graph.appliedOperations) + length(graph.operationsToApply)
|
|
|
|
end
|