Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add capability for Parallel reverse order #3

Closed
wants to merge 1 commit into from

Conversation

sanket0354
Copy link

@sanket0354 sanket0354 commented Oct 2, 2020

Add the ability for Dagwood to do reverse parallel order.

I did some testing manually on console so let's take an example of the below dependency tree:

DEPENDENCIES = {
  'A' => %w[G],
  'B' => %w[D C H I K M N O R S],
  'C' => %w[A D G J K Q],
  'D' => %w[A F G J O],
  'E' => %w[A F I J],
  'F' => %w[],
  'G' => %w[],
  'H' => %w[A F G I J N O S],
  'I' => %w[A G S],
  'J' => %w[],
  'K' => %w[A F G I J R S],
  'L' => %w[],
  'M' => %w[A F G I J O],
  'N' => %w[A F G I J M O],
  'O' => %w[A],
  'P' => %w[],
  'Q' => %w[A F G I J P],
  'R' => %w[A G H I N Q S],
  'S' => %w[],
  'T' => %w[A]
}.freeze

This is what we have when we do parallel_reverse_order:

[15] pry(main)> graph.parallel_reverse_order
=> [
["B"], 
["C"],
["K"], 
["R"], 
["H"], 
["N"],
["D", "E", "M", "Q"], 
["I", "O", "T"], 
["A"], 
["F", "G", "J", "L", "P", "S"]]

@sanket0354 sanket0354 self-assigned this Oct 2, 2020
@sanket0354 sanket0354 marked this pull request as ready for review October 5, 2020 15:11
Comment on lines +27 to +28
def parallel_reverse_order
parallel_order.reverse
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work, but my graph theory knowledge isn't quite advanced enough to convince me that its optimal... I'm just thinking of something like

B depends on A
C depends on A
D depends on C

In that case, I'd expect forwards to be [[A], [B,C], [D]]
But in reverse, couldn't we do [[B, D], [C], [A]]?

i.e. is optimal computed by "reverse the direction of the edge between each pair of nodes", and then recompute parallel_order on the resulting graph? I'm in over my head here...

I think what you've got works though, and is probably fast enough and more readable than something optimal(assuming this isn't already optimal).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be curious to see what this implementation could look like. I think this is good enough for now though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Adverbly I agree. I think your example correctly points out that the simply reversing the parallel_order may not yield the same result as re-running the algorithm on the reversed dependencies themselves. I'm unsure at this time if this could result in errors (I can't think of any cases where it would be an issue), so until we actually encounter a problem with this, I'd say it's good enough.

Comment on lines +27 to +28
def parallel_reverse_order
parallel_order.reverse

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be curious to see what this implementation could look like. I think this is good enough for now though

@julian-huff
Copy link

Version/CHANGELOG?

Comment on lines +27 to +28
def parallel_reverse_order
parallel_order.reverse
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Adverbly I agree. I think your example correctly points out that the simply reversing the parallel_order may not yield the same result as re-running the algorithm on the reversed dependencies themselves. I'm unsure at this time if this could result in errors (I can't think of any cases where it would be an issue), so until we actually encounter a problem with this, I'd say it's good enough.

@sanket0354
Copy link
Author

Closing this PR as it's not optimal enough.

@sanket0354 sanket0354 closed this Oct 6, 2020
@sanket0354 sanket0354 deleted the feature/parallel-reverse-order branch October 6, 2020 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants