Skip to content

Add support for JunctionRef (hyperedge / merged-link routing) #35

@kumilingus

Description

@kumilingus

Feature request

It would be great to have JunctionRef and its related APIs exposed in the JavaScript bindings. The underlying C++ libavoid library supports junctions for hyperedge routing, but they are currently not accessible from JS.

Motivation

When multiple connectors originate from the same connection pin, libavoid routes them as independent parallel paths. Because they share the same pin, the resulting routes overlap or run side-by-side right from the source, making it visually
unclear that they are even connected to that port.

A "merge links" feature (similar to what ELK/ELKJS provides) would solve this: links sharing a common port first travel along a single shared trunk segment, then branch off at a junction point toward their individual targets. This is the
standard tree/bus-style routing used in circuit diagrams, network topologies, and data-flow editors.

JunctionRef is the natural libavoid primitive for this — multiple ConnRefs connect to a JunctionRef branching point, and the router handles the shared-path optimization.

The C++ API docs:
https://www.adaptagrams.org/documentation/classAvoid_1_1JunctionRef.html

An example diagram with junction points:
Image

Requested APIs

The following would need embind bindings:

  • JunctionRef — constructor (router, point, id?), position(), setPositionFixed(), recommendedPosition()
  • ConnEnd.createConnEndFromJunctionRef(junctionRef, classId) — to connect a ConnRef to a junction
  • Router.deleteJunction(junctionRef) — cleanup
  • ShapeConnectionPin(junctionRef, classId, visDirs?) — junction pin constructor overload (may already work if ShapeConnectionPin accepts junctions)

Note

The routing options for junction optimization are also already exported:

  • improveHyperedgeRoutesMovingJunctions
  • improveHyperedgeRoutesMovingAddingAndDeletingJunctions

But without JunctionRef itself exposed, these options have no effect.

Also JunctionRef is already declared in the TypeScript typings (typings/libavoid.d.ts).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions