29 """Find critical path, print algorithms on it and its length."""
31 assert (tuple(
map(int, nx.__version__.split(
"."))) >=
32 (2, 0)),
"This script requires Networkx version 2.0 or higher"
34 trace = nx.read_graphml(path_to_trace_file)
36 for inNode, outNode, edge_attrs
in trace.in_edges(data=
True):
37 edge_attrs[
'Runtime'] = nx.get_node_attributes(trace,
40 cpath = nx.algorithms.dag.dag_longest_path(trace, weight=
'Runtime')
42 print(
"Algorithms on the critical path (%i): " % len(cpath))
44 print(
" {:<40} Runtime (ns)".
format(
"Name"))
45 print(
" -----------------------------------------------------")
47 print(
" {:<40}: {}".
format(trace.node[node_id].
get(
'Name'),
48 trace.node[node_id].
get(
'Runtime')))
50 print(
"\nTotal critical path time: ",
51 nx.algorithms.dag.dag_longest_path_length(trace, weight=
'Runtime'),