lib/dagwood/dependency_graph.rb
# Similar to #order, except this will group items that
# have the same "priority", thus indicating they can be done
# in parallel.
#
# Same priority means:
#  1) They have the same exact same sub-dependencies OR
#  2) B comes after A and all of B's dependencies have been resolved before A
Similar to #order, except this will group items that
have the same "priority", thus indicating they can be done
in parallel.

Same priority means:
1) They have the same exact same sub-dependencies OR
2) B comes after A and all of B's dependencies have been resolved before A
Similar to #order except this will group items that have the same " priority " thus indicating they can be done in parallel . Same priority means : 1 ) They have the same exact same sub - dependencies OR 2 ) B comes after A and all of B ' s dependencies have been resolved before A
def parallel_order
      groups = []
      ungrouped_dependencies = order.dup
      until ungrouped_dependencies.empty?
        group_starter = ungrouped_dependencies.delete_at(0)
        group = [group_starter]
        ungrouped_dependencies.each do |ungrouped_dependency|
          same_priority = @dependencies[ungrouped_dependency].all? do |sub_dependency|
            groups.reduce(false) { |found, g| found || g.include?(sub_dependency) }
          end
          group << ungrouped_dependency if same_priority
        end
        ungrouped_dependencies -= group
        groups << group.sort
      end
      groups
    end
def parallel_order groups = [ ] ungrouped_dependencies = order . dup until ungrouped_dependencies . empty? group_starter = ungrouped_dependencies . delete_at ( 0 ) group = [ group_starter ] ungrouped_dependencies . each do | ungrouped_dependency | same_priority = @dependencies [ ungrouped_dependency ] . all? do | sub_dependency | groups . reduce ( false ) { | found , g | found || g . include? ( sub_dependency ) } end group << ungrouped_dependency if same_priority end ungrouped_dependencies -= group groups << group . sort end groups end
Similar to #order, except this will group items that
have the same "priority", thus indicating they can be done
in parallel.
Similar to #order except this will group items that have the same " priority " thus indicating they can be done in parallel .
# Start this group with the first dependency we haven't grouped yet # Remove depedencies we managed to group