jamesscottbrown / pyyed

A simple Python library to export networks to yEd
BSD 3-Clause "New" or "Revised" License
81 stars 37 forks source link

Multiple edges between two nodes #19

Closed massimo-penzo-onit closed 4 years ago

massimo-penzo-onit commented 5 years ago

Hi James, First of all great library, I just started using it and it is very useful. I am trying to add multiples edges between two nodes, but seems like only the last edge in the sequence is being added, here:

g = pyyed.Graph()
g.add_node('Start', shape_fill="#8bc34a", shape="roundrectangle")
g.add_node('v_node_1', shape_fill="#ffffff", shape="roundrectangle")
g.add_edge('Start', 'v_node_1', label = "A")
g.add_edge('Start', 'v_node_1', label = "B")
g.add_edge('Start', 'v_node_1', label = "C")

The graph generated by the code above only shows edge "C", maybe I am missing something, is there a way to add multiple edges?

Regards

Massimo

Artyrm commented 5 years ago

Perhaps other edges are covered with "C" as it came last. Try to perform any auto layout in yEd, it may uncover the hidden ones.

bockor commented 4 years ago

Massimo -- This might be (too) late, however here is how I have changed the Edge class init method, which allows multiple edges between two nodes.

class Edge:

**edge_id = 1**

def __init__(self, node1, node2, label="", arrowhead="standard", arrowfoot="none",
             color="#000000", line_type="line", width="1.0"):
    self.node1 = node1
    self.node2 = node2
    **self.edge_id = 'edge' + str(Edge.edge_id)
    Edge.edge_id += 1**

Regards,

Bockor