about summary refs log tree commit diff stats
path: root/miasm2/core/graph.py
diff options
context:
space:
mode:
Diffstat (limited to 'miasm2/core/graph.py')
-rw-r--r--miasm2/core/graph.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/miasm2/core/graph.py b/miasm2/core/graph.py
index d88f8721..d35148b1 100644
--- a/miasm2/core/graph.py
+++ b/miasm2/core/graph.py
@@ -339,6 +339,22 @@ class DiGraph(object):
                                                 self.successors_iter,
                                                 self.predecessors_iter)
 
+
+
+
+    def compute_dominator_tree(self, head):
+        """
+        Computes the dominator tree of a graph
+        :param head: head of graph
+        :return: DiGraph
+        """
+        idoms = self.compute_immediate_dominators(head)
+        dominator_tree = DiGraph()
+        for node in idoms:
+            dominator_tree.add_edge(idoms[node], node)
+
+        return dominator_tree
+
     @staticmethod
     def _walk_generic_dominator(node, gen_dominators, succ_cb):
         """Generic algorithm to return an iterator of the ordered list of