Page MenuHomePhabricator

Implement getBestEffortTopographicallySortedNodesByRow on AbstractDirectedGraph
ClosedPublic

Authored by hach-que on Jul 17 2014, 3:19 AM.
Tags
None
Referenced Files
F14386586: D9956.id23981.diff
Sat, Dec 21, 1:54 PM
Unknown Object (File)
Sun, Dec 15, 12:20 PM
Unknown Object (File)
Thu, Dec 12, 2:58 AM
Unknown Object (File)
Mon, Dec 9, 8:19 AM
Unknown Object (File)
Sun, Dec 8, 10:13 AM
Unknown Object (File)
Fri, Dec 6, 1:02 PM
Unknown Object (File)
Tue, Dec 3, 8:21 AM
Unknown Object (File)
Sun, Dec 1, 9:05 AM
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).