microsoft / microsoft/automatic-graph-layout

Enforcing neighborship does not properly affect downstream nodes (Sugiyama)

Open
#283 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
1.5k
Forks
319
Avg merge
38m
Merged PRs (30d)
1

Description

I was trying to lay out several nodes/edges (DAG) by using the SugiyamaLayout, with the added requirement for certain nodes of the same layer to be positioned next to each other like this:

var settings = new Microsoft.Msagl.Layout.Layered.SugiyamaLayoutSettings();
settings.AddSameLayerNeighbors(mynodes);
Microsoft.Msagl.Miscellaneous.LayoutHelpers.CalculateLayout(fullGraph, settings, null);

While this does lead to the mentioned nodes being placed next to each other, it has almost no effect on the downstream nodes of the respective branches - i.e. the children of my nodes are placed the same way independently of whether I try to enforce the neighborship or not. Therefore the overall graph contains a lot of crossing lines if I try to enforce any neighborships - see screenshots:

Graph in its "natural" order:
image

Graph with the bottommost layer enforcing certain neighborships (excluding the root node):
image

I may have misunderstood the feature or its use, but this seems like a bug to me. If there is a better way to achieve what I want to do, please let me know. If you could just leave a few pointers of where this could be fixed in the codebase, I might even be able to invest some time into that.

PS: Please ignore the diagonal edges; my algorithm is built for drawing the graphs in a horizontal manner, but for the screenshots I wanted to simplify the code and settings as much as possible.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with SugiyamaLayoutSettings, AddSameLayerNeighbors(mynodes), and LayoutHelpers.CalculateLayout as shown. Compare downstream node ordering and edge crossings with and without enforced neighborship; done means the affected branches respond consistently to the requested same-layer ordering.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.