question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parent / child relation is not rendered when child is added before parent

See original GitHub issue

Bug 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

image

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

image

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:open
  • Created 2 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ianhicommented, Feb 2, 2022

can you try adding the following to the end your custom node init:

self.send_state("data")
1reaction
jenshnielsencommented, Jan 28, 2022

Note: I tried reproducing this by modifying https://cytoscape.org/cytoscape.js-cola/demo-compound.html and here

        elements: [
        { group: 'nodes', data: { id: 'n1', parent: 'n0'} },
        { group: 'nodes', data: { id: 'n0' } },
        ]

renders identically to

        elements: [
        { group: 'nodes', data: { id: 'n0' } },
        { group: 'nodes', data: { id: 'n1', parent: 'n0'} },
        ]
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found