sccSubGraph returns the graph of the tarjan's strongly connected components with each SCC containing at least min vertices. sccSubGraph returns nil if there is no SCC with at least min members.
(min int)
| 197 | // sccSubGraph returns nil if there is no SCC with at least min |
| 198 | // members. |
| 199 | func (t *tarjan) sccSubGraph(min int) graph { |
| 200 | if len(t.g) == 0 { |
| 201 | return nil |
| 202 | } |
| 203 | sub := make(graph, len(t.g)) |
| 204 | |
| 205 | var n int |
| 206 | for _, scc := range t.sccs { |
| 207 | if len(scc) < min { |
| 208 | continue |
| 209 | } |
| 210 | n++ |
| 211 | for _, u := range scc { |
| 212 | for _, v := range scc { |
| 213 | if _, ok := t.g[u][v]; ok { |
| 214 | if sub[u] == nil { |
| 215 | sub[u] = make(set) |
| 216 | } |
| 217 | sub[u][v] = struct{}{} |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | } |
| 222 | if n == 0 { |
| 223 | return nil |
| 224 | } |
| 225 | |
| 226 | return sub |
| 227 | } |
| 228 | |
| 229 | // set is an integer set. |
| 230 | type set map[int]struct{} |
no outgoing calls