Skip to content

Graph spacing #358

@bbenami

Description

@bbenami

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions