Neural Sketch

Routing System

Master Neural Sketch's powerful routing system for precise, elegant, and conflict-free diagram connections.

Neural Sketch's routing system is a sophisticated yet intuitive framework designed to effortlessly manage complex connections in diagrams. From simple lines to intricate, multi-path diagrams, this system ensures visual clarity, seamless intersections, and elegant routing.

Getting Started with Routing

Neural Sketch simplifies diagram connections with intuitive commands:

Basic Connection

Establish a straightforward connection between two blocks:

\nskBlock[id=A, text-center=A]
\nskBlock[id=B, pos={right=2cm of A}, text-center=B]
 
\nskConnect[from=A.east, to=B.west]

Arrow Styling

Customize arrows for clarity and emphasis:

\nskConnect[
  from=cblock.east,
  to=dblock.west,
  arrow-style={ultra thick, ->},
]
Routing Types

Arrow-tip Styling

Neural Sketch allows you to precisely customize arrow-tips independently from line styles. Using the arrow-tip property, you can adjust the arrowhead shape without affecting line attributes such as thickness, dash patterns, or curves.

This helps keep your diagrams clear and visually consistent.

Basic Example

Here’s how to define a specific arrow-tip style:

\nskConnect[
  from=blockA.east,
  to=blockB.west,
  arrow-tip={-Stealth},
]

Advanced Arrow-tip Options

Arrow-tips can accept additional TikZ customization directly through options:

\nskConnect[from=a, to=b, arrow-tip={->.>.>[sep=3mm] . Circle}]
Examples of custom arrow-tips

Comprehensive Arrow-tip Styles

Neural Sketch fully supports all advanced arrow-tip designs available in TikZ:

Supported Arrow-tip Types
Stealth
Latex
Arc Barb
Bar
Bracket
Hooks
Parenthesis
Straight Barb
Tee Barb
To
Circle
Diamond
Ellipse
Kite
Rectangle
Square
Triangle
Turned Square
Rays
Rays[n=8]

Example: Displaying All Arrow-tip Styles

\foreach \t [count=\c from 1] in {
  Stealth, Latex, Arc Barb, Bar, Bracket, Hooks, Parenthesis, Straight Barb,
  Tee Barb, To, Circle, Diamond, Ellipse, Kite, Rectangle, Square, Triangle,
  Turned Square, Rays, Rays[n=8]
}{
  \nskCoord[id=ms, y=0, x=.7*\c, marker=x]
  \nskCoord[id=me, y=1.5, x=.7*\c, marker=o]
  \nskConnect[from=ms, to=me, arrow-tip=-\t]
}
Complete set of TikZ arrow-tips

Line Cap Styles

By default, \nskConnect paths feature round line caps, offering smooth and visually pleasing terminations. Nonetheless, Neural Sketch allows choosing any supported TikZ line cap:

Supported Line Cap Styles
Butt Cap
Round Cap
Fast Round
Triangle Cap
Fast Triangle

Example: Custom Line Caps

\foreach \t [count=\c from 1] in {
  -Butt Cap[], -Round Cap[], -Round Cap[].Fast Round[].Fast Round[],
  -Triangle Cap, -Triangle Cap[].Fast Triangle[].Fast Triangle[]
}{
  \nskCoord[id=ms, y=0, x=.7*\c, marker=x]
  \nskCoord[id=me, y=1.5, x=.7*\c, marker=o]
  \nskConnect[from=ms, to=me, arrow-tip={\t}]
}
Line cap examples

Advanced Routing Features

Flexible Bend Types

Control the curvature and angles of your connections.

\nskBlock[
  type=circle,
  id=ablock,
  text-center=A,
]
\nskBlock[
  type=rectangle,
  id=bblock,
  text-center=B,
  pos={above right=1cm of ablock},
]
\nskConnect[
  from=ablock.east,
  to=bblock.south,
  bend-type=single,
  bend-direction=down,
]
Bend Routing Types

Automatic Intersection Handling

Neural Sketch elegantly handles intersecting paths, ensuring clear and readable diagrams by automatically generating bridging arcs.

Bridging Arcs (Arrow Hopping)

Activate bridging to visually distinguish crossing paths:

\nskConnect[
  from=A.east,
  to=B.west,
  bridging=true,
  bridging-style=over
]
 
\nskDoBridging
Arrow Hopping Example

Bridging Options

Fine-tune bridging behavior with these customizable options:

OptionDescriptionDefault
bridgingEnables bridging at intersections (true/false).false
bridging-stylePath precedence (over or under).under
bridging-spanLength of the bridging arc.8pt
bridging-gapGap around intersection points.4pt

Custom Bend and Routing Angles

Gain precise control over connection angles and curves:

\nskAngledc[dir=down, alpha=60]
\nskConnect[
  from=A.south,
  to=node.west,
  route={to[out=\o, in=\i]},
  arrow-style={ultra thick, stealth-},
  shorten-from=2mm
]

\nskAngledc[dir=down, alpha=60]
Custom Bend Directions
\nskAngledc[dir=left, alpha=60]
Routing Bend Types

Smooth Corner Radius

Enhance aesthetics with rounded corners on connections:

\nskConnect[
  from=A.east,
  to=B.west,
  corner-radius=5mm
]

Practical Example

Combine multiple features for robust, professional diagrams:

\begin{nskFigure}
  \nskBlock[id=A, text-center={Block A}]
  \nskBlock[id=B, pos={right=3cm of A}, text-center={Block B}]
 
  \nskConnect[
    from=A.east,
    to=B.west,
    bridging=true,
    bridging-style=over,
    corner-radius=4mm,
    bend-type=single,
    bend-direction=up,
    bend-distance=1cm,
  ]
 
  \nskDoBridging
\end{nskFigure}

Automatic Path Management

Neural Sketch's routing engine efficiently handles all path management automatically, resolving intersections and storing paths seamlessly using the underlying spath3 package. This automation reduces manual complexity, letting you concentrate fully on your diagram's structure and design.

Takeaways

  • Simplified routing and intersection resolution.
  • Unified, intuitive syntax for all routing scenarios.
  • Customizable bridging and bends enhance readability.
  • Automatic, intelligent handling of paths.
  • Professional, visually appealing diagram results.

Neural Sketch empowers you to craft publication-quality diagrams effortlessly, ensuring clarity, precision, and aesthetic excellence every step of the way.

Reference

\nskConnect Props

PropTypeDefault
shift-x?dim0mm
shift-y?dim0mm
arrow-tip?token->
arrow-style?token listultra thick, >=Triangle
bend-direction?choiceup
bend-distance?dimension1cm
bend-type?choicenone
bridging?choicefalse
bridging-gap?token list4pt
bridging-path?token listarc
bridging-span?token list8pt
bridging-style?choiceunder
color?token listc__nsk_principal
corner-radius?dimension3mm
fromtoken list{}
id?token list{}
route?token list--
shorten-from?dimension0pt
shorten-to?dimension0pt
totoken list{}

\nskAngledc Props

PropTypeDefault
alphanumber{}
dirchoice{}
dir-align?token listdown