Page MenuHomePhabricator

Implement getBestEffortTopographicallySortedNodesByRow on AbstractDirectedGraph
ClosedPublic

Authored by hach-que on Jul 17 2014, 3:19 AM.
Tags
None
Referenced Files
F14026873: D9956.id23981.diff
Fri, Nov 8, 3:02 AM
F14017811: D9956.id23980.diff
Mon, Nov 4, 11:14 PM
F14014469: D9956.id23981.diff
Sun, Nov 3, 4:59 AM
F14005983: D9956.id23981.diff
Sun, Oct 27, 11:02 PM
F13986462: D9956.diff
Mon, Oct 21, 3:07 AM
F13972738: D9956.id.diff
Thu, Oct 17, 8:58 PM
F13957860: D9956.id23980.diff
Mon, Oct 14, 11:45 AM
Unknown Object (File)
Wed, Oct 9, 5:22 PM
Subscribers

Details

Diff Detail

Repository
rPHU libphutil
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

hach-que retitled this revision from to Implement getBestEffortTopographicallySortedNodesByRow on AbstractDirectedGraph.
hach-que updated this object.
hach-que edited the test plan for this revision. (Show Details)
hach-que added a reviewer: epriestley.
epriestley edited edge metadata.
epriestley added inline comments.
src/utils/AbstractDirectedGraph.php
159–161

Since in_array() is O(N), this makes the algorithm O(N^2).

Use keys in $completed -- like $completed[$node] = true -- and isset($completed[$node]) instead, which is O(1).

Or, remove nodes from the list of remaining nodes after they're added to the results.

176–180

This seems like an odd return value.

Instead, suppose we choose one node at random/arbitrarily and mark it completed, so we always produce an ordering on all of the items (a "best effort" ordering)?

Then we could return a list of something like this:

array(
  'node' => $node,
  'depth' => /* the minimum distance from the root to the node */,
  'cycle' => /* true if we had to force our way through a cycle before we could complete this node */
)

That should be everything you need to render the data in Harbormaster.

This revision now requires changes to proceed.Jul 17 2014, 9:43 PM
hach-que edited edge metadata.

Changes based on feedback

hach-que edited edge metadata.

Actually write code that works

epriestley edited edge metadata.
This revision is now accepted and ready to land.Jul 18 2014, 2:09 AM
hach-que updated this revision to Diff 23981.

Closed by commit rPHU8ddea4ef8c67 (authored by @hach-que).