Skip to content

Commit 32ed9ed

Browse files
author
askeblad
authored
correct spelling of DFS.GForrest (#214)
> > would it break code to change to `GForest` ? > > I think it wouldn't, since `alex` is an executable only and does not export an API. > But also, there are no strong reasons to correct the misspelling, are there? > (These lines mostly haven't been touched in 19 years, so we should have some respect ... :-D) noting the computer science studies component of graph theory, the change is indicated Skogen och vår identitet by Erkki Lähde Finlands natur - 1984 Prof. Lähde recounts when as a young graduate out of forestry studies, he had the occasion to visit a village in the Finnish countryside. He noticed in the area a group of trees which to his view was overdue to be cut. But enquiring upon the local villagers of that stand of trees, the reply was that there was an old woman from the village who had liked to walk among that grove. Thus the trees were saved out of piety. > (These lines mostly haven't been touched in 19 years, so we should have some respect ... :-D) piety isn't indicated here
1 parent 7d16ef0 commit 32ed9ed

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/DFS.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ import qualified Set hiding ( Set )
2929
import Data.Array ( (!), accumArray, listArray )
3030

3131
-- The result of a depth-first search of a graph is a list of trees,
32-
-- `GForrest'. `post_order' provides a post-order traversal of a forrest.
32+
-- `GForest'. `post_order' provides a post-order traversal of a forest.
3333

34-
type GForrest = [GTree]
35-
data GTree = GNode Int GForrest
34+
type GForest = [GTree]
35+
data GTree = GNode Int GForest
3636

37-
postorder:: GForrest -> [Int]
37+
postorder:: GForest -> [Int]
3838
postorder ts = po ts []
3939
where
4040
po ts' l = foldr po_tree l ts'
@@ -87,33 +87,33 @@ t_close g@(sz,_) = (sz,\v->ar!v)
8787
ar = listArray (0,sz) ([postorder(dff' [v] g)| v<-vertices g]++[und])
8888
und = error "t_close"
8989

90-
scc:: Graph -> GForrest
90+
scc:: Graph -> GForest
9191
scc g = dff' (reverse (top_sort (reverse_graph g))) g
9292

9393
top_sort:: Graph -> [Int]
9494
top_sort = postorder . dff
9595

9696

97-
-- `dff' computes the depth-first forrest. It works by unrolling the
97+
-- `dff' computes the depth-first forest. It works by unrolling the
9898
-- potentially infinite tree from each of the vertices with `generate_g' and
9999
-- then pruning out the duplicates.
100100

101-
dff:: Graph -> GForrest
101+
dff:: Graph -> GForest
102102
dff g = dff' (vertices g) g
103103

104-
dff':: [Int] -> Graph -> GForrest
104+
dff':: [Int] -> Graph -> GForest
105105
dff' vs (_bs, f) = prune (map (generate_g f) vs)
106106

107107
generate_g:: (Int->[Int]) -> Int -> GTree
108108
generate_g f v = GNode v (map (generate_g f) (f v))
109109

110-
prune:: GForrest -> GForrest
110+
prune:: GForest -> GForest
111111
prune ts = snd(chop(empty_int,ts))
112112
where
113113
empty_int:: Set Int
114114
empty_int = Set.empty
115115

116-
chop:: (Set Int,GForrest) -> (Set Int,GForrest)
116+
chop:: (Set Int,GForest) -> (Set Int,GForest)
117117
chop p@(_, []) = p
118118
chop (vstd,GNode v ts:us) =
119119
if v `Set.member` vstd

0 commit comments

Comments
 (0)