Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pipeline/src/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ def has_property(self, name):
if property.name == name:
return True
return False

def __eq__(self, other: Node) -> bool:

for property in self.properties:
property_other = getattr(other, property.name, None)
property_self = getattr(self, property.name, None)
if property_other != property_self:
return False

return True

def to_jsonld(self, include_empty_properties=True, embed_linked_nodes=True, with_context=True):
"""
Expand Down
12 changes: 12 additions & 0 deletions pipeline/src/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ def __len__(self):

def __iter__(self):
return iter(self.nodes.values())

def __eq__(self, other):

# The current implementation assumes that nodes in both graphs are connected with the same link number.
for node_id in self.nodes:
if node_id in other.nodes.keys():
if self.nodes[node_id] != other.nodes[node_id]:
return False
else:
return False

return True

def add(self, *nodes):
"""
Expand Down