56 lines
1.3 KiB
Julia
56 lines
1.3 KiB
Julia
|
function show_nodes(io, graph::DAG)
|
||
|
print(io, "[")
|
||
|
first = true
|
||
|
for n in graph.nodes
|
||
|
if first
|
||
|
first = false
|
||
|
else
|
||
|
print(io, ", ")
|
||
|
end
|
||
|
print(io, n)
|
||
|
end
|
||
|
print(io, "]")
|
||
|
end
|
||
|
|
||
|
function show(io::IO, graph::DAG)
|
||
|
println(io, "Graph:")
|
||
|
print(io, " Nodes: ")
|
||
|
|
||
|
nodeDict = Dict{Type, Int64}()
|
||
|
noEdges = 0
|
||
|
for node in graph.nodes
|
||
|
if haskey(nodeDict, typeof(node.task))
|
||
|
nodeDict[typeof(node.task)] = nodeDict[typeof(node.task)] + 1
|
||
|
else
|
||
|
nodeDict[typeof(node.task)] = 1
|
||
|
end
|
||
|
noEdges += length(parents(node))
|
||
|
end
|
||
|
|
||
|
if length(graph.nodes) <= 20
|
||
|
show_nodes(io, graph)
|
||
|
else
|
||
|
print("Total: ", length(graph.nodes), ", ")
|
||
|
first = true
|
||
|
i = 0
|
||
|
for (type, number) in zip(keys(nodeDict), values(nodeDict))
|
||
|
i += 1
|
||
|
if first
|
||
|
first = false
|
||
|
else
|
||
|
print(", ")
|
||
|
end
|
||
|
if (i % 3 == 0)
|
||
|
print("\n ")
|
||
|
end
|
||
|
print(type, ": ", number)
|
||
|
end
|
||
|
end
|
||
|
println(io)
|
||
|
println(io, " Edges: ", noEdges)
|
||
|
properties = graph_properties(graph)
|
||
|
println(io, " Total Compute Effort: ", properties.compute_effort)
|
||
|
println(io, " Total Data Transfer: ", properties.data)
|
||
|
println(io, " Total Compute Intensity: ", properties.compute_intensity)
|
||
|
end
|