Graph spacing

Open
#358 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp

Research direction

Start with the reproduced C# example, especially GraphRenderer.CalculateLayout and the assignments to NodeSeparation and LayerSeparation. Compare the calculated node positions and graph dimensions with the custom 150x80 node boundaries. The issue is done when those separation settings visibly affect the rendered layout, or their intended behavior is documented.

Written by the indexing model from the issue text.

Description

I use custom node size and the graph looks too dense. I tried to make more space between the nodes by setting the node separation and layer separation but they both do not seems to make any effect.

       Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("");
        graph.AddEdge("A", "B");
        graph.AddEdge("B", "C");
        graph.AddEdge("C", "D");
        graph.AddEdge("C", "E");
        graph.AddEdge("C", "F");
        graph.AddEdge("C", "G");
        graph.AddEdge("A", "H");
        graph.AddEdge("E", "H");
        graph.AddEdge("F", "H");

        foreach (var node in graph.Nodes)
        {
            int w = 150;
            int h = 80;

            node.NodeBoundaryDelegate = new DelegateToSetNodeBoundary(p => CurveFactory.CreateRectangle(w, h, new Microsoft.Msagl.Core.Geometry.Point()));
        }


        graph.Attr.LayerDirection = LayerDirection.LR;
        graph.Attr.NodeSeparation = 200;
        graph.Attr.LayerSeparation = 200;

        Microsoft.Msagl.GraphViewerGdi.GraphRenderer renderer = new Microsoft.Msagl.GraphViewerGdi.GraphRenderer(graph);
        renderer.CalculateLayout();

        int width = 1500;
        Bitmap bitmap = new Bitmap(width, (int)(graph.Height * (width / graph.Width)), PixelFormat.Format32bppPArgb);
        renderer.Render(bitmap);
        bitmap.Save("c:\\temp\\test2.png");

image

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

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.

More from microsoft/automatic-graph-layout

All issues in microsoft/automatic-graph-layout

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.