microsoft / microsoft/automatic-graph-layout
Constraints in FastIncrementalLayoutSettings
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 319
- Avg merge
- 38m
- Merged PRs (30d)
- 1
Description
Hello!
I am trying to create layout for a graph using fast incremental algorithm, but can't make constraints work: they are not called at all during algorithm execution.
What am I doing wrong?
Code is as follows:
// creating settings object
var layoutSettings = new FastIncrementalLayoutSettings();
// creating and adding constraint
var c = new HorizontalSeparationConstraint(leftNode, rightNode, 200);
layoutSettings.AddStructuralConstraint(c);
// executing layout calculation
Microsoft.Msagl.Miscellaneous.LayoutHelpers.CalculateLayout(graph, layoutSettings, null);
I am sure that my node objects are in graph.
With a little research I have found that settings object is being copied before calculations through constructor public FastIncrementalLayoutSettings(FastIncrementalLayoutSettings previousSettings), and the collection of constraints are not being transferred into new object there. Meaning, there are no constraints present during calculations.
If I copy reference to the collection into new object, then I encounter exception:
hc.LeftNode.AlgorithmData has type AlgorithmDataNodeWrap, but is casted to FiNode in AxisSolver.AddStructuralConstraints() method, resulting in exception.
Am I using library in a wrong way or is there an actual bug?
I really need to get that constraints working.
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 by reproducing the provided example with FastIncrementalLayoutSettings and inspect the FastIncrementalLayoutSettings(FastIncrementalLayoutSettings previousSettings) constructor. Then trace AxisSolver.AddStructuralConstraints() and the constraint collection and node AlgorithmData types. Done means structural constraints are retained through layout calculation and execute without the reported cast exception.
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
- 35/100