Populating a graph and retrieving node positions not working
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 30/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- csharp
- Domain
- computer-graphics
Research direction
Start with the supplied construction and position-reading sequence around Microsoft.Msagl.Core.Layout.Node, GeometryGraph, SugiyamaLayoutSettings, and LayeredLayout.Run(). Reproduce the overlapping positions, then determine what correction is required and how curved edges around nodes should be handled. Done means the example yields distinct node positions and addresses the edge-routing question.
Written by the indexing model from the issue text.
Description
I am trying to use the MSAGL library to generate node positions. I have gone through the samples and have not found a simple example that helps.
I have my own custom Graph object with a list of custom edges and custom nodes. I am iterating through them, adding them to the GeometryGraph, creating a layered layout, running the graph, iterating back through the nodes, and retrieving the node positions. The resulting nodes positions are incorrect, they are just about all overlapping. I tried scaling the positions by 100x but they still overlap. What am I doing wrong?
(Here's my code)
- I create nodes and edges. I make a dictionary for the nodes so I can reuse them in my edges.
Dictionary<string, Microsoft.Msagl.Core.Layout.Node> nMap = new Dictionary<string, Microsoft.Msagl.Core.Layout.Node>();
int radius = 12;
foreach (var myNode in myGraph.nodes)
{
var curve = CurveFactory.CreateCircle(radius, new Point());
// var node = new Microsoft.Msagl.Core.Layout.Node(curve, id);
var node = new Microsoft.Msagl.Core.Layout.Node(curve, myNode.id.ToString());
graph.Nodes.Add(node);
nMap.Add(myNode.id.ToString(), mNode);
}
foreach (var activity in myGraph.activities)
{
var source = nMap[activity.chartInfo.source_id.ToString()];
var target = nMap[activity.chartInfo.target_id.ToString()];
graph.GeometryGraph.Edges.Add(new Microsoft.Msagl.Core.Layout.Edge(source, target));
}
- Then I create my layout settings. I've tried changing properties on the settings to see if they produce different positions
var settings = new SugiyamaLayoutSettings
{
Transformation = PlaneTransformation.Rotation(Math.PI / 2),
EdgeRoutingSettings = { EdgeRoutingMode = Microsoft.Msagl.Core.Routing.EdgeRoutingMode.Spline }
};
// Tested these out but they didn't work
settings.MinimalHeight = 700;
settings.MinimalWidth = 1300;
settings.NodeSeparation = 200;
var llayout = new LayeredLayout(graph.GeometryGraph, settings);
llayout.Run();
- Then I get my custom nodes (from a dictionary lookup) and set the positions from the GeometryGraph nodes:
foreach(var node in graph.GeometryGraph.Nodes)
{
var myNode = myGraphNodeMap[node.UserData.ToString()];
myNode .x = (int)node.Center.X * 100;
myNode .y = (int)node.Center.Y* 100;
}
Can someone point me in the right direction? What am I doing wrong?
As an aside, how would you create edges that curve around a node?
- 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
- 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.
More from microsoft/automatic-graph-layout
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
microsoft/automatic-graph-layout#395 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
microsoft/automatic-graph-layout#390 · 6 comments · 2 reactions · 2 assignees ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
microsoft/automatic-graph-layout#389 · 1 comment · 1 reaction ·
All issues in microsoft/automatic-graph-layout
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·