2023-08-29 12:57:46 +02:00
|
|
|
"""
|
|
|
|
graph_properties(graph::DAG)
|
|
|
|
|
|
|
|
Return the graph's properties, a named tuple with fields `.data`, `.compute_effort`, `.compute_intensity`, `.nodes` (number of nodes) and `.edges` (number of edges).
|
|
|
|
"""
|
2023-08-24 15:11:54 +02:00
|
|
|
function graph_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
|
|
|
|
2023-08-25 10:48:22 +02:00
|
|
|
d = 0
|
|
|
|
ce = 0
|
|
|
|
ed = 0
|
|
|
|
for node in graph.nodes
|
|
|
|
d += data(node.task) * length(node.parents)
|
|
|
|
ce += compute_effort(node.task)
|
|
|
|
ed += length(node.parents)
|
|
|
|
end
|
2023-08-24 15:11:54 +02:00
|
|
|
|
2023-08-25 10:48:22 +02:00
|
|
|
ci = ce / d
|
2023-08-24 15:11:54 +02:00
|
|
|
|
2023-08-25 10:48:22 +02:00
|
|
|
result = (
|
|
|
|
data = d,
|
|
|
|
compute_effort = ce,
|
|
|
|
compute_intensity = ci,
|
|
|
|
nodes = length(graph.nodes),
|
|
|
|
edges = ed,
|
|
|
|
)
|
|
|
|
return result
|
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
|