FM gain of moving local vertex `v` from its side to the other. `+w` for each net where `v`'s side has exactly one pin (the move uncuts it); `−w` for each net fully on `v`'s side with ≥2 pins (the move newly cuts it).
(lv: Level<'_>, ns: &NetState, side: &[u8], v: usize)
| 808 | cnt[i][side[v as usize] as usize] += 1; |
| 809 | } |
| 810 | if cnt[i][0] > 0 && cnt[i][1] > 0 { |
| 811 | cut += u128::from(*w); |
| 812 | } |
| 813 | } |
| 814 | (NetState { cnt }, cut) |
| 815 | } |
| 816 | } |
| 817 | |
| 818 | /// FM gain of moving local vertex `v` from its side to the other. |
| 819 | /// `+w` for each net where `v`'s side has exactly one pin (the move uncuts it); |
| 820 | /// `−w` for each net fully on `v`'s side with ≥2 pins (the move newly cuts it). |
| 821 | fn fm_gain(lv: Level<'_>, ns: &NetState, side: &[u8], v: usize) -> i128 { |
| 822 | let a = side[v] as usize; |
| 823 | let b = 1 - a; |
| 824 | let mut g: i128 = 0; |
| 825 | for &ni in &lv.vnets[v] { |
| 826 | let (w, pins) = &lv.nets[ni as usize]; |
| 827 | if pins.len() > FM_NET_CAP { |
| 828 | continue; // hub net: ignored by FM |
| 829 | } |
| 830 | let ca = ns.cnt[ni as usize][a]; |
| 831 | let cb = ns.cnt[ni as usize][b]; |