cytoscape / cytoscape.js

Graph theory (network) library for visualisation and analysis
https://js.cytoscape.org
MIT License
9.98k stars 1.63k forks source link

Unbundled bezier edge disappear or flip when nodes are close #3251

Open anthonyhtyao opened 1 month ago

anthonyhtyao commented 1 month ago

Environment info

Current (buggy) behaviour

Unbundled bezier edges disappear (2nd) or flip (3rd) when two nodes are next to each other or overlap as shown below Screenshot from 2024-07-01 12-21-19

p.s. there is an ancient issue about the flip #411

Desired behaviour

The second and third edges should display similarly to the first one

Minimum steps to reproduce

Here is the js code to reproduce the image above

cytoscape({
    "container": document.getElementById("cy"),
     "elements": [
         {"data": {"id": 1}, "position": {"x": 0, "y": 0}},
         {"data": {"id": 2}, "position": {"x": 40, "y": 0}},
         {"data": {"id": 3}, "position": {"x": 0, "y": 40}},
         {"data": {"id": 4}, "position": {"x": 20, "y": 40}},
         {"data": {"id": 5}, "position": {"x": 0, "y": 80}},
         {"data": {"id": 6}, "position": {"x": 19, "y": 80}},
         {"data": {"source": 1, "target": 2}}, // normal
         {"data": {"source": 3, "target": 4}}, // disappear
         {"data": {"source": 5, "target": 6}}, // flip
    ],
    "style": [
         {"selector": "node", "style": {"width": 20, "height": 20}},
         {"selector": "edge", "style": {"curve-style": "unbundled-bezier", "control-point-weight": 0.5, "control-point-distance": 20}},
    ],
    "layout": {"name": "preset"},
})

For reviewers

Reviewers should ensure that the following tasks are carried out for incorporated issues:

maxkfranz commented 1 month ago

Great start to the issue. Let's get this in a demo so we can move forward, @anthonyhtyao

maxkfranz commented 1 month ago

Assigning to @anthonyhtyao until his demo is posted

anthonyhtyao commented 1 month ago

Hi, here is the demo

AlexanderPico commented 1 month ago

Thanks for the demo. While we look into fixing this for the automatic case, you might consider the manual control option for edge path in cases where you need a solution now.