-
Notifications
You must be signed in to change notification settings - Fork 0
/
Node.hs
32 lines (23 loc) · 851 Bytes
/
Node.hs
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
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
module Node where
import Data.Vector
--Show is so the objective value of a node can be displayed
class (Ord a, Show a) => Node n a | n -> a where
f :: n -> a
neighbours :: n -> Vector n
--Heuristic Node, for heuristic algorithms
class (Node n a) => HNode n a where
h :: n -> a
--Traceable Node, for parent tracing
class (Node n a) => TNode n a where
parent :: n -> Maybe n
--Goal Node, for problems with a well-defined goal node
class (Node n a) => GNode n a where
isGoal :: n -> Bool
--Show Node, for use with algorithms which show partial results during run time
class (Show n, Node n a) => SNode n a
maxComp :: (Node n a) => n -> n -> Ordering
maxComp a b = compare (f b) (f a)
minComp :: (Node n a) => n -> n -> Ordering
minComp a b = compare (f a) (f b)