microsoft / microsoft/automatic-graph-layout
Graph spacing
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 319
- Avg merge
- 38m
- Merged PRs (30d)
- 1
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");
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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.
Assessment
- Tech stack
- csharp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100