Skip to content

Add Barnes-Hut optimization to Atlas2 NAD layout#733

Merged
flo-dup merged 207 commits intomainfrom
693-barnes_hut
Mar 17, 2026
Merged

Add Barnes-Hut optimization to Atlas2 NAD layout#733
flo-dup merged 207 commits intomainfrom
693-barnes_hut

Conversation

@NathanDissoubray
Copy link
Copy Markdown
Contributor

@NathanDissoubray NathanDissoubray commented Sep 29, 2025

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • A PR or issue has been opened in all impacted repositories (if any)

Does this PR already have an issue describing the problem?

Closes #693
Waiting for the merge of #721

What kind of change does this PR introduce?

This PR adds a faster calculation of the repulsion force (known as Barnes-Hut) for Atlas2 in the NAD, which allows the bigger network like an 8k nodes to be done in less than 100s. Networks of less than 1000 nodes are done in less than 1s.
Those numbers do not include any potential post-processing (such as an overlap prevention, which might add 1 or 2 seconds of calculation on top of that).

What is the current behavior?

Networks of 8k nodes take about 2k-3k seconds, networks of 1k nodes take about 8s

What is the new behavior (if this is a feature change)?

image Some networks don't have as much as a gain as others, those are the networks where we can see a torsion in the graph (basically it forms an X), so Barnes-Hut can't optimize as much because nodes are in a less favorable position). We still gain time for all graph with this method though. The visual does not change in any noticeable way.

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

If yes, please check if the following requirements are fulfilled

  • The Breaking Change or Deprecated label has been added
  • The migration steps are described in the following section

What changes might users need to make in their application due to this PR? (migration steps)

Other information:

This was used to push nodes away from the center of the edge between
other nodes. The goal of this was to reduce edge crossing, but it just
pushes edge crossings to the the side, instead of the middle of edges
(not removing the edge at all). This is usually less readable because
edge crossings are closer to actual nodes, and it also makes
calculations longer.

Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Also change Vector2D to a record to simplify the code

Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Make a class for each way to calculate the force instead, store the
artifacts needed for that in the class directly

Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
…to define SpringyAlgorithm

Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
…r each time

Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
There is no optimization or post-processing yet, that will come later

Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
…e not NO_CHILDREN

Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
Note: this creates a bit of code duplication
Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
…list

Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
The TODO was mentionned in the stoppingCriteria interface issue

Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
Comment thread diagram-util/src/main/java/com/powsybl/diagram/util/layout/geometry/Vector2D.java Outdated
Comment thread diagram-util/src/main/java/com/powsybl/diagram/util/layout/geometry/Quadtree.java Outdated
Comment thread diagram-util/src/main/java/com/powsybl/diagram/util/layout/geometry/Quadtree.java Outdated
Comment thread diagram-util/src/main/java/com/powsybl/diagram/util/layout/geometry/Quadtree.java Outdated
Comment thread diagram-util/src/main/java/com/powsybl/diagram/util/layout/geometry/Quadtree.java Outdated
Comment thread diagram-util/src/main/java/com/powsybl/diagram/util/layout/geometry/Quadtree.java Outdated
Comment thread diagram-util/src/main/java/com/powsybl/diagram/util/layout/geometry/Quadtree.java Outdated
Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
… construction

Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: Nathan Dissoubray <nathan.dissoubray@rte-france.com>
…Barycenter)

Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
Signed-off-by: NathanDissoubray <nathan.dissoubray@rte-france.com>
@sonarqubecloud
Copy link
Copy Markdown

@flo-dup flo-dup merged commit e336ced into main Mar 17, 2026
8 checks passed
@flo-dup flo-dup deleted the 693-barnes_hut branch March 17, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rewrite of the layout calculation algorithm for the Network Area Diagram

2 participants