Skip to content

Edge routed off into the middle of nowhere #406

Closed

Description

@fedarko

Test case: components 1 and 2 (which are reverse-complementary twins) in the Verkko 1.2 HG002 graph (https://s3-us-west-2.amazonaws.com/human-pangenomics/T2T/scratch/HG002/assemblies/graphs/20220812/assembly.homopolymer-compressed.noseq.gfa) --

Image

zoomed in on this:

Image

This is not an artifact of me cleaning up the layout utils code from yesterday - this problem persists even on the old redundant-ccs branch.

When I write out the causal DOT code and lay it out using dot on the CLI, the edge appears fine. Need to figure out where the weird control points are coming from.

Activity

  1. added
    external
    layout
    on Mar 26, 2026
  2. fedarko commented on Mar 27, 2026

    @fedarko
    MemberAuthor
    • using shape=rect (instead of the house / invhouse things) fixes the issue for cc2, but makes the problem worse for cc1 lol

    • upgrading the graphviz version installed to 14.x still suffers from the problem, albeit the problem now impacts different edges in the same graph (???????)

    • laying out the graph outside of pgv does not produce this problem, and even using the pygraphviz .draw() method to a PDF or something works fine. maybe there is some sort of overflow happening?

    • for testing an xdot, you can run neato -n2 test.xdot > test.svg in order to at least visualize the positions (running dot instead of neato will cause problems since it doesn't respect -n2 -- https://stackoverflow.com/a/19435272)

    • the xdot coordinates seem right. if you open up the SVGs from above in inkscape or something the weird edges in question seem perfectly fine, and even if you compare their pos attributes to other edges there are not any obvious problems

    • using subprocess.run("dot -Txdot lay.dot > lay.xdot", shell=True) to lay out the graph outside of graphviz, then loading the xdot back into pygraphviz, does not fix things

    • the cpd / cpw control points we are producing for Cytoscape.js also seem right. below, the 139-target edge (-utig4-69) is the one with the goofy routing, and yet its control points seem very similar to its surroundings.

    Image

    It seems like this might be a Cytoscape.js thing, for some obscure reason?


    If there is a way to detect these kinds of problems then I can try to flatten these edges... but I am not aware yet of a way to do this after passing data to Cytoscape.js.

    • the _private.bbCache and _private.bodyBounds are much higher for the goofy edge. Maybe we can compute the histogram of all of these values for each edge, detect outliers, and flatten them?
    • the _private.rstyle.bezierpts are also clearly crazy, see below
    Image

    So maybe we can implement something similar to the bad-edge rescuing that - given a bounding box computed from the nodes in the graph (cy.nodes().boundingBox()), plus some generous tolerance - detects edges with control points that leave this bounding box and flattens them.

    ok, how about

    let nodeBB = cy.nodes().boundingBox();
    for (var i = 0; i < cy.edges().length; i ++) {
      var e = cy.edges()[i];
      if (e._private.bodyBounds.x1 < nodeBB.x1 - 100 || e._private.bodyBounds.x2 > nodeBB.x2 + 100 || e._private.bodyBounds.y1 < nodeBB.y1 - 100 || e._private.bodyBounds.y2 > nodeBB.y2 + 100) {
        e.removeClass("withctrlpts");
      }
    }

    Should ideally also report this as a Cytoscape.js issue, so confused by why this is even happening

  3. added 2 commits that reference this issue on Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugexternallayout

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions