Giter Club home page Giter Club logo

Comments (4)

hdahmou avatar hdahmou commented on June 14, 2024

Hi,

I think I know what's the problem, I believe that it might be related to the offset used when drawing edges. In the current implementation, the offset is set as the size of the node, which works well when using circular shapes because the distance from the edge of the circle to the center of the shape is the same, regardless of the angle.

However, when using "non-uniform" shapes like triangles, the offset should depend on the angle. For non-directed graphs, a quick workaround is to reduce the offset, for example, with node_size[target] * 0.5. However, this solution might not work with directed graphs as the arrow may get hidden by the node. Additionally, it may cause strange artifacts when using small nodes and thick edges.

from netgraph.

paulbrodersen avatar paulbrodersen commented on June 14, 2024

Hi Hicham,

Yeah, this is a known issue. The problem is very similar to issue #37, which is about providing support for arbitrary node shapes derived from text boxes, which runs into the same sort of problems. You are also absolutely right with your diagnosis, as well as the assessment that there isn't an easy fix that doesn't cause problems in other places. In issue #37, I outlined some of the things that I believe would need to be done to properly address this problem, and I have even started to work on it on a (local) branch.

In theory, the solution is quite straightforward: simply compute the intersection between the matplotlib Path that defines the node artist and then shorten the edge accordingly. This approach works well for paths forming convex polygons. The problem that I got stuck on was how to handle paths that are Bezier curves (i.e. circles and rectangles with rounded corners, for example). Here, the path does not correspond to the outline of the patch but only defines it implicitly.
Properly supporting arbitrary node shapes also raises issues in other places, e.g. with the automatic scaling of node label fontsizes.

All of this a long-winded way of saying that I am interested in properly handling arbitrary node shapes and actively working on it but the problem is complex. Since I am short on time at the moment (work is busy and I have a 9 month old baby at home), it will take me a good while (months not days) until the issue will be resolved. If you are interested in working on this in the meantime, I am happy to draw up a proper roadmap.

Thanks for chiming in on the other issue,
Paul

from netgraph.

paulbrodersen avatar paulbrodersen commented on June 14, 2024

Some progress:

test_offset_curved_edge

from netgraph.

paulbrodersen avatar paulbrodersen commented on June 14, 2024

On the dev branch, edges now connect precisely to their targets for arbitrary node shapes.
I am in the process of preparing a new major release, and it hence will be some time until dev will get merged into the master branch. To install the dev branch, use:

pip install https://github.com/paulbrodersen/netgraph/archive/dev.zip

from netgraph.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.