MCPcopy Index your code
hub / github.com/gonum/plot / sccSubGraph

Method sccSubGraph

plotter/johnson.go:199–227  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

197// sccSubGraph returns nil if there is no SCC with at least min
198// members.
199func (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.
230type set map[int]struct{}

Callers 2

cyclesInFunction · 0.80
TestTarjanFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestTarjanFunction · 0.64