AddToEdgeDiv increases the weight of an edge between two nodes. If there isn't such an edge one is created.
(to *Node, dv, v int64, residual, inline bool)
| 126 | // AddToEdgeDiv increases the weight of an edge between two nodes. If |
| 127 | // there isn't such an edge one is created. |
| 128 | func (n *Node) AddToEdgeDiv(to *Node, dv, v int64, residual, inline bool) { |
| 129 | if n.Out[to] != to.In[n] { |
| 130 | panic(fmt.Errorf("asymmetric edges %v %v", *n, *to)) |
| 131 | } |
| 132 | |
| 133 | if e := n.Out[to]; e != nil { |
| 134 | e.WeightDiv += dv |
| 135 | e.Weight += v |
| 136 | if residual { |
| 137 | e.Residual = true |
| 138 | } |
| 139 | if !inline { |
| 140 | e.Inline = false |
| 141 | } |
| 142 | return |
| 143 | } |
| 144 | |
| 145 | info := &Edge{Src: n, Dest: to, WeightDiv: dv, Weight: v, Residual: residual, Inline: inline} |
| 146 | n.Out[to] = info |
| 147 | to.In[n] = info |
| 148 | } |
| 149 | |
| 150 | // NodeInfo contains the attributes for a node. |
| 151 | type NodeInfo struct { |