diff --git a/include/mgp.py b/include/mgp.py index 7a369686e..467164a3f 100644 --- a/include/mgp.py +++ b/include/mgp.py @@ -158,6 +158,16 @@ class EdgeType: def name(self) -> str: return self._name + def __eq__(self, other) -> bool: + if isinstance(other, EdgeType): + return self.name == other.name + if isinstance(other, str): + return self.name == other + return NotImplemented + + def __hash__(self) -> int: + return hash(self.name) + class Edge: '''Edge in the graph database. @@ -218,6 +228,9 @@ class Edge: raise InvalidContextError() return self._edge == other._edge + def __hash__(self) -> int: + return hash((self.from_vertex, self.to_vertex, self.type)) + if sys.version_info >= (3, 5, 2): VertexId = typing.NewType('VertexId', int) @@ -304,6 +317,9 @@ class Vertex: raise InvalidContextError() return self._vertex == other._vertex + def __hash__(self) -> int: + return hash(self.id) + class Path: '''Path containing Vertex and Edge instances.'''