Skip to content

Commit e3c44f2

Browse files
committed
✨ Add attribute and set_attribute to Edge()
1 parent 209c5db commit e3c44f2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pynode_next/edge.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ def __init__(self, source, target, weight=None, directed=False):
1414

1515
self._internal_id = uuid.uuid4()
1616

17+
self._attrs = {}
18+
1719
def other_node(self, node):
1820
"""Returns the other node than the specified node in the edge."""
1921
return (
@@ -34,6 +36,14 @@ def target(self, source=None):
3436
return self.other_node(source)
3537
return self._target
3638

39+
def set_attribute(self, name, value):
40+
"""Sets an attribute of the edge"""
41+
self._attrs[name] = value
42+
43+
def attribute(self, name):
44+
"""Gets an attribute of the edge"""
45+
return self._attrs[name]
46+
3747
def traverse(self, initial_node=None, color=Color.RED, keep_path=True):
3848
if initial_node == None:
3949
source = self._source

0 commit comments

Comments
 (0)