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

Function TestTarjan

plotter/johnson_test.go:325–354  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

323}
324
325func TestTarjan(t *testing.T) {
326 for i, test := range graphTests {
327 var g graph
328 if test.path != nil {
329 g = graphFrom(test.path)
330 } else {
331 g = test.g
332 }
333 tar := newTarjan(g)
334 gotSCCs := tar.sccs
335 if test.orderIsAmbiguous {
336 // We lose topological order here, but that
337 // is not important for this use case.
338 sort.Sort(byComponentLengthOrStart(test.wantSCCs))
339 sort.Sort(byComponentLengthOrStart(gotSCCs))
340 }
341 // tarjan.strongconnect does range iteration over maps,
342 // so sort SCC members to ensure consistent ordering.
343 for _, scc := range gotSCCs {
344 sort.Ints(scc)
345 }
346 if !reflect.DeepEqual(gotSCCs, test.wantSCCs) {
347 t.Errorf("unexpected tarjan scc result for %d:\n\tgot:%v\n\twant:%v", i, gotSCCs, test.wantSCCs)
348 }
349 gotAdj := tar.sccSubGraph(2)
350 if !reflect.DeepEqual(gotAdj, test.wantAdj) {
351 t.Errorf("unexpected tarjan sccSubGraph(2) result for %d:\n\tgot:%#v\n\twant:%#v", i, gotAdj, test.wantAdj)
352 }
353 }
354}
355
356func TestJohnson(t *testing.T) {
357 for i, test := range graphTests {

Callers

nothing calls this directly

Calls 4

graphFromFunction · 0.85
newTarjanFunction · 0.85
byComponentLengthOrStartTypeAlias · 0.85
sccSubGraphMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…