Add plotting and generate plots
This commit is contained in:
@ -50,7 +50,7 @@ end
|
||||
function partners(node::Node)
|
||||
result = Set{Node}()
|
||||
for child in children(node)
|
||||
for partner in parents(node)
|
||||
for partner in parents(child)
|
||||
if (partner != node)
|
||||
push!(result, partner)
|
||||
end
|
||||
@ -111,7 +111,7 @@ function graph_properties(graph::DAG)
|
||||
ce = 0
|
||||
ed = 0
|
||||
for node in graph.nodes
|
||||
d += data(node.task)
|
||||
d += data(node.task) * length(node.parents)
|
||||
ce += compute_effort(node.task)
|
||||
ed += length(node.parents)
|
||||
end
|
||||
@ -136,10 +136,9 @@ end
|
||||
|
||||
function can_reduce(n1::Node, n2::Node)
|
||||
if (n1.task != n2.task)
|
||||
return false
|
||||
return false
|
||||
end
|
||||
|
||||
return parents(n1) == parents(n2)
|
||||
return Set(children(n1)) == Set(children(n2))
|
||||
end
|
||||
|
||||
function can_split(n::Node)
|
||||
|
@ -10,6 +10,7 @@ function push_operation!(graph::DAG, operation::Operation)
|
||||
|
||||
# 3.: Regenerate properties, possible operations from here
|
||||
|
||||
graph.possibleOperations.dirty = true
|
||||
end
|
||||
|
||||
# reverts the latest applied operation, essentially like a ctrl+z for
|
||||
@ -29,6 +30,7 @@ function pop_operation!(graph::DAG)
|
||||
|
||||
# 3.: Regenerate properties, possible operations from here
|
||||
|
||||
graph.possibleOperations.dirty = true
|
||||
end
|
||||
|
||||
can_pop(graph::DAG) = !isempty(graph.operationsToApply) || !isempty(graph.appliedOperations)
|
||||
@ -192,7 +194,7 @@ function node_reduction!(graph::DAG, n1::Node, n2::Node)
|
||||
n2_children = children(n2)
|
||||
n2_parents = parents(n2)
|
||||
|
||||
if n2_children != children(n1)
|
||||
if Set(n2_children) != Set(children(n1))
|
||||
error("[Node Reduction] The given nodes do not have equal prerequisite nodes which is required for node reduction")
|
||||
end
|
||||
|
||||
@ -226,11 +228,14 @@ function node_split!(graph::DAG, n1::Node)
|
||||
error("[Node Split] The given node does not have multiple parents which is required for node split")
|
||||
end
|
||||
|
||||
for parent in n1_parents
|
||||
remove_edge!(graph, make_edge(n1, parent))
|
||||
end
|
||||
|
||||
for parent in n1_parents
|
||||
n_copy = copy(n1)
|
||||
insert_node!(graph, n_copy)
|
||||
insert_edge!(graph, make_edge(n_copy, parent))
|
||||
remove_edge!(graph, make_edge(n1, parent))
|
||||
|
||||
for child in n1_children
|
||||
insert_edge!(graph, make_edge(child, n_copy))
|
||||
@ -288,7 +293,7 @@ function generate_options(graph::DAG)
|
||||
if can_reduce(node, partner)
|
||||
if reductionVector === nothing
|
||||
# only when there's at least one reduction partner, insert the vector
|
||||
reductionVector = Vector{Node}
|
||||
reductionVector = Vector{Node}()
|
||||
push!(reductionVector, node)
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user