cytoscape / ipycytoscape

A Cytoscape Jupyter widget
https://ipycytoscape.readthedocs.io/en/master/
BSD 3-Clause "New" or "Revised" License
269 stars 62 forks source link

printing out Graph & style data of an Ipycytoscape #202

Closed joseberlines closed 3 years ago

joseberlines commented 3 years ago

I observe the following behaviour:

if you print the nodes of a graph: G.graph.nodes you get:

[Node(data={'id': 'BER', 'label': 'HBf BER', 'classes': 'east'}, position={}),
 Node(data={'id': 'MUN', 'label': 'HBf MUN', 'classes': 'west'}, position={}),

a list of nodes The same applies for edges.

But, when you do: G.get_style

the output is: <bound method CytoscapeWidget.get_style of CytoscapeWidget(cytoscape_layout={'name': 'cola'}, cytoscape_style=[[[{'selector': "node[id='BER']", ...

In order to be consistent I would expect two methods to show the list of styles (without the layout) and another method for a layout.

something like: G.stylewould give a list: [{'selector': "node[id='BER']", ...`

and G.layout would give: ['cola']

I think this would be more consistent and would help to debug and build graphs in notebooks.

Actually: print(type(G.graph.nodes)) is spectate.models.List

but print(G.get_style) is method

I think all should be the same kind of data, i.e. edges, nodes, style and layout.

EDIT1: This will allow easier comparison of graph style properties

ianhi commented 3 years ago

If I call the function G.get_style() then I get the output I think you're expecting: image

you can also do: print(G.cytoscape_style)

Probably the cytoscape_style attribute should be renamed to style but that's a very backwards incompatible change.