summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2014-05-02 03:32:12 +1000
committerJed Barber <jjbarber@y7mail.com>2014-05-02 03:32:12 +1000
commit4b0fd5fe80607e1487659acfdc51cc95a1b7effe (patch)
tree1709371fdc0f43134d37546f18550684d11eb2fb
parent1294b57dbbec16f2b9c1a07542a970f38e1b735d (diff)
Grasp program isomorphic comparison half done
-rw-r--r--src/Grasp/Parser.hs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/Grasp/Parser.hs b/src/Grasp/Parser.hs
index e7c920d..1ddbb94 100644
--- a/src/Grasp/Parser.hs
+++ b/src/Grasp/Parser.hs
@@ -1,7 +1,10 @@
module Grasp.Parser (
GraspProgram(..),
+ GraspData(..),
parseGrasp,
+ nodesWithName,
+ iso,
dup
) where
@@ -26,6 +29,14 @@ type StrLNode a = (String,a)
type StrLEdge a = (String,String,a)
+type GraspData = ([StrLNode String],[StrLEdge String])
+
+
+
+instance (Ord a, Ord b) => Eq (Gr a b) where
+ a == b = ((sort . Graph.labNodes $ a) == (sort . Graph.labNodes $ b)) &&
+ ((sort . Graph.labEdges $ a) == (sort . Graph.labEdges $ b))
+
@@ -88,6 +99,28 @@ constructGraph = uncurry Graph.mkGraph
+nodesWithName :: GraspProgram -> String -> [LNode String]
+nodesWithName g s = []
+
+
+
+normalise :: GraspData -> ([LNode String],[LEdge String])
+normalise (n,e) = ([],[])
+
+
+
+iso :: GraspProgram -> GraspProgram -> Bool
+iso a b =
+ let f (x,y) = (show x, y)
+ g (x,y,z) = (show x, show y, z)
+
+ -- converts a grasp program into grasp data
+ h x = ((map f) . Graph.labNodes $ x, (map g) . Graph.labEdges $ x)
+
+ in (constructGraph . normalise . h $ a) == (constructGraph . normalise . h $ b)
+
+
+
dup :: (Eq a) => [a] -> Maybe a
dup x =
let dup' [] _ = Nothing