microsoft / microsoft/automatic-graph-layout

Subgraph Box Geo Transform

Open
#252 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

After graph.CreateGeometryGraph(), each Node has populated geometry. When we write to SVG we use a transpose to flip y-coordinate (TransformGraphByFlippingY). This does not touch the geometry on the subgraph, making the node and edge geo not intersect with the subgraph box, this only becomes an issue when wanting to draw the subgraph (for example, as a box).
There are two ways around this:

  1. Manually transpose the GeometryNode on the subgraph before using the subgraph geo:
graph.RootSubgraph.AllSubgraphsDepthFirstExcludingSelf()
|> Seq.iter (fun e -> e.GeometryNode.Transform(PlaneTransformation(1., 0., 0., 0., -1., 0.)))
  1. Add the actual subgraph to the geometry, after CreateGeometryGraph, before using the subgraph geometry (e.g. SvgWriter)

graph.GeometryGraph.Nodes.Add(actualSubgraph.GeometryNode)

I am not sure which is the correct way of doing it, but provided they both occur post-layout, it shouldn't affect things dramatically

I don't think this is a bug, but it took me a good couple hours so solve, so I wanted to document somewhere others could find it.

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.

Research direction

Start with the CreateGeometryGraph, TransformGraphByFlippingY, and SvgWriter entry points mentioned in the report, then compare the two post-layout workarounds for subgraph geometry. Document the confirmed approach and the conditions under which subgraph boxes align with their nodes and edges.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
computer-graphics, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.