Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Commit

Permalink
Data Tree & other algo
Browse files Browse the repository at this point in the history
  • Loading branch information
Vonfry committed May 23, 2017
1 parent 35c3a9c commit f0cd8c3
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aima-haskell.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ source-repository head


library
-- exposed-modules:
exposed-modules: Data.Aima.Tree
-- other-modules:
-- other-extensions:
build-depends: base >=4.9 && <4.10
Expand Down
Empty file added src/Data/Aima/Graph.hs
Empty file.
38 changes: 38 additions & 0 deletions src/Data/Aima/Tree.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
-- | A tree data struct.

module Data.Aima.Tree where


-- | Tree class.
--
-- @t@ is a tree data. It should have a param to save the node type.
--
-- I suggest every instance of this class also instance "Eq" and "Ord"
class Tree t where
{-# MINIMAL parentTree, childrentTree, nodeT, insTree, delTree, orderTree #-}

-- | Get the parent node of a tree.
parentTree :: t a -> t a

-- | Get the childrent trees of a tree.
childrentTree :: t a -> [t a]

-- | Get the current node of a tree.
nodeT :: t a -> a

-- | Insert a new node to an existing tree.
insTree :: t a -> a -> t a

-- | Delete a current node from the tree.
delTree :: t a -> t a

-- | Order the tree.
orderTree :: t a -> t a


-- | A Tree Node data.
data TreeNode a = TreeNode {
parent :: TreeNode a -- ^ parent node.
, children :: [TreeNode a] -- ^ childrent. If you want to use BTree, set the count of children is 2.
, node :: a -- ^ node. It contains the context and some other info.
}
Empty file added src/Search/AStar.hs
Empty file.
Empty file added src/Search/BFS.hs
Empty file.
Empty file added src/Search/DFS.hs
Empty file.
Empty file added src/Search/RBFS.hs
Empty file.

0 comments on commit f0cd8c3

Please sign in to comment.