Skip to content

feat: SameNetTraceMergeSolver — merge close same-net trace segments#424

Open
wbobbynmworley wants to merge 2 commits into
tscircuit:mainfrom
wbobbynmworley:feat/same-net-trace-merge-solver
Open

feat: SameNetTraceMergeSolver — merge close same-net trace segments#424
wbobbynmworley wants to merge 2 commits into
tscircuit:mainfrom
wbobbynmworley:feat/same-net-trace-merge-solver

Conversation

@wbobbynmworley
Copy link
Copy Markdown

Problem

Fixes #29 (bounty: $100)

When multiple trace segments belong to the same net, they should be merged into a single continuous trace if their endpoints are close enough. This reduces visual clutter and ensures the schematic renderer produces cleaner output.

Solution

New pipeline phase SameNetTraceMergeSolver inserted between TraceCleanupSolver and NetLabelPlacementSolver.

Net identification priority: userNetIdglobalConnNetIddcConnNetId

Merge logic:

  1. Group traces by net
  2. For each group, build adjacency graph based on endpoint proximity (threshold configurable, default 0.1mm)
  3. Connected components → merged traces:
  • Axis-aligned gaps: direct concatenation (shared x or y)
  • Noise gaps (< threshold on both axes): direct concat with tolerance
  • Non-axis-aligned gaps: L-bridge insertion (horizontal then vertical segment to bridge)

Key differences from PR #351:

Testing

8 unit test cases covering:

  • Basic same-net merge (2 adjacent traces)
  • Different nets NOT merged
  • Gap exceeding threshold NOT merged
  • L-bridge insertion for diagonal gaps
  • Three sequential traces merged
  • Reversed endpoint matching
  • Single-trace nets unchanged
  • userNetId priority

Files Changed

  • lib/solvers/SameNetTraceMergeSolver/SameNetTraceMergeSolver.ts — solver implementation
  • lib/solvers/SameNetTraceMergeSolver/SameNetTraceMergeSolver.test.ts — 8 test cases
  • lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts — pipeline integration

@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
schematic-trace-solver Ready Ready Preview, Comment May 24, 2026 2:22pm

Request Review

New pipeline phase that merges trace segments belonging to the same
net when their endpoints are within a configurable threshold (default
0.1mm). Handles axis-aligned connections (direct concat), small gaps
(noise tolerance), and non-axis-aligned gaps (L-bridge insertion).

Priority order for net identification: userNetId > globalConnNetId > dcConnNetId.

Replaces PR tscircuit#351 with a cleaner implementation that integrates properly
into the pipeline (between TraceCleanupSolver and NetLabelPlacementSolver).

Includes comprehensive unit tests (8 test cases).

Closes tscircuit#29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New Phase To combine same-net trace segments that are close together

1 participant