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