Parent / child relation is not rendered when child is added before parent
See original GitHub issueBug report
Bug summary
Rendering of parent child relationship depends on the order of nodes being added
Code for reproduction
Consider the following CustomNode class which sets an optional parent child relationship
from typing import Optional
import ipycytoscape
class CustomNode(ipycytoscape.Node):
"""
A node class that contains the correct information for visualization
with ipycytoscape
"""
def __init__(self, name: str, classes: str = "", parent: Optional[str] = None):
super().__init__()
self.data["id"] = name
if parent is not None:
self.data["parent"] = parent
self.classes = classes
If I create a graph manually adding first the parent and then the child
graphwidget = ipycytoscape.CytoscapeWidget()
graphwidget.graph.add_nodes([CustomNode(name="node1", parent=None), CustomNode(name="node2", parent="node1")])
graphwidget
This correctly renders the parent child relation ship
However if I add the nodes in the reverse order:
graphwidget = ipycytoscape.CytoscapeWidget()
graphwidget.graph.add_nodes([CustomNode(name="node2", parent="node1"), CustomNode(name="node1", parent=None)])
graphwidget
The parent child relationship is not shown
Actual outcome
Parent child relationship is only shown when parent is added to the graph before child.
Expected outcome
Parent Child relationships is independent of the order of the nodes being added.
Version Info
- ipycytoscape version (
import ipycytoscape; print(ipycytoscape.__version__)
) : 1.3.2 - Python version: 3.8.12 and 3.10.0
- Jupyter(Lab) version: jupyterlab 3.2.8
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
The mystery of React Element, children, parents and re-renders
Children are not children, parents are not parents, memoization doesn't work as it should, life is meaningless, re-renders control our life and ...
Read more >java - JPA OneToOne relation doesnt persist child entity when ...
When creating a suggestion I am setting the reference to the parent, and in the parent the reference to the child, like this:...
Read more >Chapter 161. Termination of The Parent-child Relationship
(f) The court shall not render an order terminating parental rights under Subsection (b)(4) unless the court, after reviewing the petitioner's sworn affidavit ......
Read more >Parent, child and sibling relationships – Figma Help Center
A Frame by itself is not automatically a parent. It is only a parent if there are objects within it. If a parent...
Read more >Add a parent or child company to an existing company record
In HubSpot, you have the ability to associate companies in a parent-child relationship. You can add parent or child companies on a record...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
can you try adding the following to the end your custom node init:
Note: I tried reproducing this by modifying https://cytoscape.org/cytoscape.js-cola/demo-compound.html and here
renders identically to