about summary refs log tree commit diff stats
path: root/miasm2/core/graph.py
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2016-01-25 10:47:16 +0100
committerAjax <commial@gmail.com>2016-01-25 14:28:41 +0100
commitb4d46020aff6aac57b79cfcb64011bdc608854d9 (patch)
treee52ea2c358ed662c958fcaabb3f1cffda790f7ad /miasm2/core/graph.py
parentb3fae7887d63bcdbb18b25ade6d20f152d802005 (diff)
downloadmiasm-b4d46020aff6aac57b79cfcb64011bdc608854d9.tar.gz
miasm-b4d46020aff6aac57b79cfcb64011bdc608854d9.zip
Graph: two graphs are equals if they have the same nodes and edges
Diffstat (limited to 'miasm2/core/graph.py')
-rw-r--r--miasm2/core/graph.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/miasm2/core/graph.py b/miasm2/core/graph.py
index 49fc0817..f38f71d6 100644
--- a/miasm2/core/graph.py
+++ b/miasm2/core/graph.py
@@ -1,5 +1,6 @@
 from collections import defaultdict, namedtuple
 
+
 class DiGraph(object):
     """Implementation of directed graph"""
 
@@ -25,6 +26,12 @@ class DiGraph(object):
     def edges(self):
         return self._edges
 
+    def __eq__(self, graph):
+        if not isinstance(graph, self.__class__):
+            return False
+        return all((self._nodes == graph.nodes(),
+                    sorted(self._edges) == sorted(graph.edges())))
+
     def add_node(self, node):
         if node in self._nodes:
             return