jamesscottbrown / pyyed

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

edge between a NODE and a GROUPNODE #28

Closed bockor closed 4 years ago

bockor commented 4 years ago

yEd in native way permits to create edges between a node and a group node.
The current pyyed group class has unfortunately not this method available. I would appreciate if it could be implemented or at least investigated.

I have attached a screen shot how it is looking in native yEd.

Cheers,

edge_between_node_and_node-group_constructed_in_yed

bockor commented 4 years ago

After some trial-and-error sessions I've managed to achieve the above topology using this code snippet. I don't believe it was ever intended in the first pace, but it works for me now.

import pyyed

# create instance of the Graph class
g = pyyed.Graph()

# Create groupnode MAIN add node N1
main = g.add_group('MAIN')
main.add_node('N1')

# Create groupnode SUB and nodes N2, N3
sub = g.add_group('SUB')
sub.add_node('N2')
sub.add_node('N3')

# Move groupnode SUB into groupnode MAIN
main.add_group('SUB')

# Make the connections (edges)
g.add_edge('SUB','N1', arrowhead='none')

# Write to file in
g.write_graph('node_to_group_edge.graphml', pretty_print=True)
bockor commented 4 years ago

My findings on te current pyyed multi level GroupNode Graph institution using the method I have brought on 3 days from here.

The trade off is that the graphml file contains a duplication of these movedGroupNodes. The GroupNode within the Graph context will be used to construct the edges. So this is not a workable solution a all.

In a previous life I have assembled a PHP script that exported networks to yEd. The script was also multi level GroupNode capable. I had two types of edges: inter and intra Graph. The inter Graph edges were encapsulated into the context of the relevant GroupNodes. At the end, the remaining intra GroupNode edges were inserted. See the attached pic. graphml_file_structure

So my conclusion is that the pyyed GroupNode is missing a method to create edges within its context (GroupNode.add_edge() ...).

bockor commented 4 years ago

Issue solved by commit https://github.com/jamesscottbrown/pyyed/pull/36