subgraph returns a subgraph of g induced by {s, s+1, ... , n}. The subgraph is destructively generated in g.
(s int)
| 244 | // subgraph returns a subgraph of g induced by {s, s+1, ... , n}. The |
| 245 | // subgraph is destructively generated in g. |
| 246 | func (g graph) subgraph(s int) graph { |
| 247 | for u := range g[:s] { |
| 248 | g[u] = nil |
| 249 | } |
| 250 | for u, e := range g[s:] { |
| 251 | for v := range e { |
| 252 | if v < s { |
| 253 | delete(g[u+s], v) |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | return g |
| 258 | } |
| 259 | |
| 260 | // clone returns a deep copy of the graph g. |
| 261 | func (g graph) clone() graph { |