Skip to content

Commit

Permalink
✨ add edge.set_width() and edge.width()
Browse files Browse the repository at this point in the history
  • Loading branch information
ehne committed Aug 14, 2021
1 parent 3540b5b commit dfeca95
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions pynode_next/edge.py
Expand Up @@ -13,6 +13,8 @@ def __init__(self, source, target, weight=None, directed=False):
if weight == None:
self._weight = ""

self._thickness = 2

self._color = Color.LIGHT_GREY

self._internal_id = uuid.uuid4()
Expand Down Expand Up @@ -87,11 +89,21 @@ def set_directed(self, directed=True):
self._directed = directed
core.ax(lambda x: self._dispatch_wrapper(x, {"directed": directed}))
return self

def directed(self):
"""Returns whether or not the edge is directed"""
return self._directed


def set_width(self, weight=2):
"""Sets the thickness of the edge."""
self._thickness = weight
core.ax(lambda x: self._dispatch_wrapper(x, {"thickness": weight}))
return self

def width(self):
"""Returns the thickness of the edge."""
return self._weight

def traverse(self, initial_node=None, color=Color.RED, keep_path=True):
if initial_node == None:
source = self._source
Expand Down Expand Up @@ -137,6 +149,7 @@ def _data(self):
"target": str(self._target),
"directed": self._directed,
"labels": {1: {"text": str(self._weight)}},
"thickness": self._thickness
}
}
}
Expand Down

0 comments on commit dfeca95

Please sign in to comment.