forked from soniakeys/graph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trav.go
50 lines (42 loc) · 1.33 KB
/
trav.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2017 Sonia Keys
// License MIT: http://opensource.org/licenses/MIT
package main
import (
"github.com/soniakeys/bits"
"github.com/soniakeys/graph"
"github.com/soniakeys/graph/alt"
)
func DFSmall() (string, string) {
b := bits.New(chungLuSmall.Order())
alt.DepthFirst(chungLuSmall.AdjacencyList,
chungLuSmallCCRep, alt.Visited(&b))
return "DepthFirst", chungLuSmallCCTag
}
func DFLarge() (string, string) {
b := bits.New(chungLuLarge.Order())
alt.DepthFirst(chungLuLarge.AdjacencyList,
chungLuLargeCCRep, alt.Visited(&b))
return "DepthFirst", chungLuLargeCCTag
}
func BFSmall() (string, string) {
chungLuSmall.AdjacencyList.BreadthFirst(chungLuSmallCCRep,
func(graph.NI) {})
return "BreadthFirst", chungLuSmallCCTag
}
func BFLarge() (string, string) {
chungLuLarge.AdjacencyList.BreadthFirst(chungLuLargeCCRep,
func(graph.NI) {})
return "BreadthFirst", chungLuLargeCCTag
}
func AltBFSmall() (string, string) {
g := chungLuSmall.AdjacencyList
alt.BreadthFirst2(g, g, chungLuSmallCCma, chungLuSmallCCRep, nil,
func(graph.NI) bool { return true })
return "DO BreadthFirst", chungLuSmallCCTag
}
func AltBFLarge() (string, string) {
g := chungLuLarge.AdjacencyList
alt.BreadthFirst2(g, g, chungLuLargeCCma, chungLuLargeCCRep, nil,
func(graph.NI) bool { return true })
return "DO BreadthFirst", chungLuLargeCCTag
}