From ca4ebae36c58b66962766776d89ae172092a95cb Mon Sep 17 00:00:00 2001 From: Brenden Kokoszka Date: Mon, 15 Feb 2016 21:27:15 -0800 Subject: [PATCH] Setting up basic outline for visualization app --- .gitignore | 2 +- Main.elm | 12 ------------ UkkonenAlgorithm.elm | 8 ++++---- UkkonenVisualization.elm | 23 +++++++++++++++++++++++ index.html | 28 ++++++++++++++++++++++++++++ 5 files changed, 56 insertions(+), 17 deletions(-) delete mode 100644 Main.elm create mode 100644 UkkonenVisualization.elm create mode 100644 index.html diff --git a/.gitignore b/.gitignore index e453cba..3bd52a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ elm-stuff -index.html +elm.js diff --git a/Main.elm b/Main.elm deleted file mode 100644 index 19ea063..0000000 --- a/Main.elm +++ /dev/null @@ -1,12 +0,0 @@ -import Html exposing (pre, text) -import Html.Attributes exposing (class) -import Graphics.Element exposing (show) - -import UkkonenTree exposing (..) -import UkkonenAlgorithm exposing (..) - -main = let - string = "abcabxabcd" - tree = UkkonenAlgorithm.buildTree string - in - pre [] [text (UkkonenTree.toString tree)] diff --git a/UkkonenAlgorithm.elm b/UkkonenAlgorithm.elm index 2eccf2b..48ab9fd 100644 --- a/UkkonenAlgorithm.elm +++ b/UkkonenAlgorithm.elm @@ -219,11 +219,11 @@ insert' newChar state = until all n steps have been taken. -} walkEdge : Array Char -> ActivePoint -> Char -> Int -> UkkonenTree -> ActivePoint -walkEdge string activePoint char n tree = +walkEdge string activePoint c n tree = case getEdge activePoint.nodeId - char + c tree of Just activeEdge -> @@ -237,7 +237,7 @@ walkEdge string activePoint char n tree = end - activeEdge.labelStart in if n <= activeEdgeLength then - { activePoint | edge = Just ( char, n ) } + { activePoint | edge = Just ( c, n ) } else walkEdge string @@ -249,7 +249,7 @@ walkEdge string activePoint char n tree = Nothing -> Debug.crash ("Tried to reference edge " - ++ (Basics.toString ( activePoint.nodeId, char )) + ++ (Basics.toString ( activePoint.nodeId, c )) ++ ", which doesn't exist" ) diff --git a/UkkonenVisualization.elm b/UkkonenVisualization.elm new file mode 100644 index 0000000..f22dfc7 --- /dev/null +++ b/UkkonenVisualization.elm @@ -0,0 +1,23 @@ +module UkkonenVisualization (..) where + +import Html exposing (pre, text) +import Html.Attributes exposing (class) +import Graphics.Element exposing (show) +import Json.Encode as Json +import Window +import UkkonenTree exposing (..) +import UkkonenAlgorithm exposing (..) + + +port tree : Signal Json.Value +port tree = + Signal.map (\( w, h ) -> Json.list [ Json.int w, Json.int h ]) Window.dimensions + + +main = + let + string = "abcabxabcd" + + tree = UkkonenAlgorithm.buildTree string + in + pre [] [ text (UkkonenTree.toString tree) ] diff --git a/index.html b/index.html new file mode 100644 index 0000000..e952645 --- /dev/null +++ b/index.html @@ -0,0 +1,28 @@ + + + Ukkonen's algorithm for linear-time suffix tree construction + + + + + +

foo

+
+
+ + + +