Algorithm Search⌘K

Problemadvanced

River routing

Also called single-layer planar routing.

Connect two rows of terminals in order by non-crossing wires on one layer. Leiserson and Pinter and others give exact tests of separation in linear time.

River routing is the form of channel routing with only one layer. Two rows of terminals face each other across a channel, terminal ii on the top must be joined to terminal ii on the bottom, and the wires may not cross or touch, since there is no second layer to pass over. The name comes from the picture of wires that flow side by side like a river. The terminals must be in the same order on both sides, or no routing exists. Unlike two-layer channel routing, which is NP-complete, river routing has exact answers in linear time: whether a channel of a given width is wide enough, how wide it must be, and how far one row may be shifted against the other. Leiserson and Pinter in 1983 and Tompa in 1980 gave such results.

In plain words

Picture two rows of posts on the two banks of a river, numbered from left to right. Each post on the north bank must be joined by a string to the post with the same number on the south bank. The strings lie flat on the ground and may not cross or touch, and they may only run north to south or east to west, on the lines of a grid.

If a post on the north bank is far to the left of its partner, its string must run across the river at a slant, in steps. Strings next to it must then make the same steps, and a group of strings that all go the same way needs room. The question is how wide the river must be so that all strings fit.

Definition

Input.

  • Two sequences of integers a1<a2<⋯<ana_1 < a_2 < \cdots < a_n and b1<b2<⋯<bnb_1 < b_2 < \cdots < b_n, the columns of the top terminals and of the bottom terminals.
  • A width h≥1h \ge 1, the number of rows inside the channel.

Grid. The routing grid is the unit grid graph on the points (x,y)(x, y) with xx any integer and 0≤y≤h+10 \le y \le h + 1. Rows 1 to hh are the inside of the channel. Top terminal ii is the point (ai,h+1)(a_i, h + 1), and bottom terminal ii is the point (bi,0)(b_i, 0). The channel is open to the left and to the right, so its length is not limited.

Feasible solution. For each ii, a path in the grid from (bi,0)(b_i, 0) to (ai,h+1)(a_i, h + 1) whose other points are all inside the channel, such that the nn paths are vertex-disjoint. This is the one-layer Manhattan model.

Questions.

  • Routability. Given aa, bb and hh, does a feasible solution exist?
  • Least width. Given aa and bb, find the least hh that is routable.
  • Offset. Given the two rows up to a shift ss of the top row (so ai+sa_i + s in place of aia_i), find the shifts for which a width hh is routable, or the least width over all shifts. Leiserson and Pinter call this the placement problem for river routing.

Order. Terminal ii is joined to terminal ii. A layout with wires on one layer is a planar drawing, and two wires that connect the rows in a different order would have to cross, so the order condition is part of the definition, not an extra rule.

Variants

  • Fixed length. The channel has a given length as well as a given width. Wires must then stay between the outer columns.
  • Several rows of terminals. Terminals on more than two sides, or on blocks inside the region. The general one-layer routing of many nets around obstacles is harder.
  • Other wire shapes. Wires at 45 degrees, or in the Euclidean plane, with a minimum distance between wires. The width bounds change, but the method of cuts below stays.
  • Minimum wire length or bends. Among routings in the least width, minimize the total length or the number of bends.
  • Two-layer channel routing. With a second layer the order condition goes away, and the problem becomes the channel routing problem.

Examples

A shift by one. Top a=(2,3,4,5)a = (2, 3, 4, 5), bottom b=(1,2,3,4)b = (1, 2, 3, 4). Each wire must move one column to the right, into the column where the next wire starts. For h=3h = 3 the cut condition fails, since b4−a1=2<3b_4 - a_1 = 2 < 3, so four wires would have to pass a diagonal with three points. The least width is 4, one row for the step of each wire: wire 4 turns in row 1, wire 3 in row 2, and so on.

Rows far apart. Top a=(1,2,3)a = (1, 2, 3), bottom b=(4,5,6)b = (4, 5, 6). For h=1h = 1 and h=2h = 2 the cut condition fails (a2−b1=−2a_2 - b_1 = -2 and a3−b1=−1a_3 - b_1 = -1), and for h=3h = 3 there is nothing to check, so the least width is 3. Wire 1 turns left in row 1, wire 2 in row 2 and wire 3 in row 3.

Rows that interleave. Top a=(1,3,5)a = (1, 3, 5), bottom b=(2,4,6)b = (2, 4, 6). A width of 1 is enough: wire ii goes up from (2i,0)(2i, 0) to row 1, left to column 2i−12i - 1, and up to the top. The wires use the columns 2i−12i - 1 and 2i2i in row 1, which are all different.

A mixed case. Top a=(1,2,6,7)a = (1, 2, 6, 7), bottom b=(3,4,5,6)b = (3, 4, 5, 6). A width of 1 fails, because a2−b1=−1<1a_2 - b_1 = -1 < 1: wires 1 and 2 start at columns 3 and 4 and end at columns 1 and 2, so both must pass the single point (3,1)(3, 1) of the diagonal. For h=2h = 2 the four differences a3−b1a_3 - b_1, a4−b2a_4 - b_2, b3−a1b_3 - a_1 and b4−a2b_4 - a_2 are 3, 3, 4 and 4, all at least 2, so the least width is 2.

Out of order. If the top row lists the nets as 1, 2 and the bottom row as 2, 1, no width is enough, while a two-layer channel routes the same pins.

Known algorithms

The exact algorithms are in the cited papers, and this page does not list their steps.

Question What is known
Routability for given hh decided in linear time (Leiserson and Pinter 1983); the cut condition below takes O(n)O(n) time for one hh
Least width found exactly (Tompa 1980 and 1981); with the cut condition, a binary search over hh takes O(nlog⁡n)O(n \log n) time
Offset the shifts of one row that allow a given width are found in linear time (Leiserson and Pinter 1983)
Routability for any width, by brute force a maximum flow on the grid, as in the reductions below; correct but slow

Bounds

Cut condition. If width hh is routable, then for every ii with i+h≤ni + h \le n,

ai+h−bi≥handbi+h−ai≥h.a_{i + h} - b_i \ge h \quad\text{and}\quad b_{i + h} - a_i \ge h.

Proof of the first inequality. Suppose ai+h−bi≤h−1a_{i+h} - b_i \le h - 1. Let DD be the set of grid points with x−y=bi−1x - y = b_i - 1. Inside the channel, DD has exactly hh points, (bi−1+y,y)(b_i - 1 + y, y) for 1≤y≤h1 \le y \le h. The bottom terminals bi,…,bi+hb_i, \ldots, b_{i+h} have x−y=bj≥bix - y = b_j \ge b_i, so they lie on the side x−y>bi−1x - y > b_i - 1. The top terminals ai,…,ai+ha_i, \ldots, a_{i+h} have x−y=aj−h−1≤ai+h−h−1≤bi−2x - y = a_j - h - 1 \le a_{i+h} - h - 1 \le b_i - 2, so they lie on the side x−y<bi−1x - y < b_i - 1. Each step of a grid path changes x−yx - y by 1, so each of the h+1h + 1 wires i,…,i+hi, \ldots, i + h passes through a point of DD. Its only points in rows 0 and h+1h + 1 are its own ends, which are not on DD, so that point is inside the channel. The wires are disjoint, so DD would need h+1h + 1 points inside the channel. The second inequality follows in the same way with the diagonal x+y=ai+hx + y = a_i + h, which has hh points inside the channel: if bi+h−ai≤h−1b_{i+h} - a_i \le h - 1, the bottom terminals bi,…,bi+hb_i, \ldots, b_{i+h} have x+y≤ai+h−1x + y \le a_i + h - 1 and the top terminals ai,…,ai+ha_i, \ldots, a_{i+h} have x+y≥ai+h+1x + y \ge a_i + h + 1. □\square

Width formula. The terminals are strictly increasing integers, so if the cut condition holds for hh it holds for h+1h + 1. The least width is therefore the least h≥1h \ge 1 that meets the cut condition. Necessity is proved above. That the cut condition is also sufficient is the content of the cited works, and this page does not prove it. The form given here agrees with an exhaustive search by maximum flow on every instance with n≤5n \le 5 and terminals in columns 0 to 7. That is a test on small cases, not a proof.

Upper bound. For h=nh = n the cut condition has no pairs to check, so by the formula width nn is always enough.

Relation to cuts in general. The routing is a set of vertex-disjoint paths in a grid, which is a planar graph. The diagonals DD are vertex cuts in the sense of the max-flow min-cut theorem, and the width formula says that in this setting the diagonal cuts are the only ones that matter.

Reductions

  • To disjoint paths in a planar grid. River routing is a case of the vertex-disjoint paths problem with all sources on one face and all sinks on another, in order. Here, unlike the general problem, the cut condition is enough.
  • To maximum flow. For a fixed hh, joining a super source to all bottom terminals and a super sink to all top terminals, with unit capacities on the grid points, gives a flow of value nn exactly when the routing exists. Disjoint paths that cross the strip from the bottom row to the top row keep their order from left to right, so the ii-th path from the left joins bib_i to aia_i. This is a correct but slow test.
  • From two-layer channels. The order condition shows the gap to the two-layer channel routing problem: a second layer allows any order, at the price of NP-hardness (NP-completeness of channel routing).

Applications

  • Joining blocks on one metal layer. When two blocks of a chip face each other with their pins in the same order, for example a data path and its memory, a river route on one layer joins them without vias.
  • Placement of blocks. The offset question tells how far apart, and how much shifted, two blocks must be placed so that one layer is enough between them.
  • Power and clock lines, and packages. Wiring that must stay on one layer, such as some power lines, and the fan-out from a chip to a package, use the same model, with the escape routing of pin arrays as a related problem.

References

  1. Charles E. Leiserson and Ron Y. Pinter, Optimal placement for river routing, SIAM Journal on Computing 12(3), 447 to 462, 1983, the conditions for routing two rows of terminals in a channel of given width, and the optimal offset of the two rows (general locator)
  2. Martin Tompa, An optimal solution to a wire-routing problem, Journal of Computer and System Sciences 23(2), 127 to 150, 1981, the least width of a single-layer channel for terminals in order on two sides; first presented at STOC 1980, 161 to 176 (general locator)
  3. Naveed A. Sherwani, Algorithms for VLSI Physical Design Automation, third edition, Kluwer, 1999, the chapter on detailed routing, the part on single-layer routing (general locator)
  4. Andrew B. Kahng, Jens Lienig, Igor L. Markov and Jin Hu, VLSI Physical Design, From Graph Partitioning to Timing Closure, second edition, Springer, 2022, Chapter 6, Detailed Routing (general locator; single-layer routing as a special case of channel routing)

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a known algorithm
  • a contract.yaml