summaryrefslogtreecommitdiff
path: root/Source/Graph/Graph.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Graph/Graph.cs')
-rw-r--r--Source/Graph/Graph.cs19
1 files changed, 18 insertions, 1 deletions
diff --git a/Source/Graph/Graph.cs b/Source/Graph/Graph.cs
index 768f499e..6bfd5c34 100644
--- a/Source/Graph/Graph.cs
+++ b/Source/Graph/Graph.cs
@@ -761,7 +761,24 @@ namespace Graphing {
return;
}
-
+ public IEnumerable<Node> SortHeadersByDominance()
+ {
+ Graph<Node> dag = new Graph<Node>();
+ foreach (Node b in headers)
+ {
+ dag.AddSource(b);
+ foreach (Node c in headers)
+ {
+ if (b.Equals(c)) continue;
+ if (DominatorMap.DominatedBy(b, c))
+ {
+ Debug.Assert(!DominatorMap.DominatedBy(c, b));
+ dag.AddEdge(b, c);
+ }
+ }
+ }
+ return dag.TopologicalSort();
+ }
} // end: class Graph
public class GraphProgram {