Skip to content

Commit

Permalink
Setting up basic outline for visualization app
Browse files Browse the repository at this point in the history
  • Loading branch information
brenden committed Feb 16, 2016
1 parent c5fec6f commit ca4ebae
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
elm-stuff
index.html
elm.js
12 changes: 0 additions & 12 deletions Main.elm

This file was deleted.

8 changes: 4 additions & 4 deletions UkkonenAlgorithm.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand All @@ -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
Expand All @@ -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"
)

Expand Down
23 changes: 23 additions & 0 deletions UkkonenVisualization.elm
Original file line number Diff line number Diff line change
@@ -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) ]
28 changes: 28 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<html>
<head>
<title>Ukkonen's algorithm for linear-time suffix tree construction</title>
<script src="elm.js"></script>
<style>
#ukkonen-visualization {
height: 100%;
}
</style>
</head>

<body>
<h1>foo</h1>
<div id="tree-graph"></div>
<div id="ukkonen-visualization"></div>
</body>

<script type="text/javascript">
// Show the stamp module in the "elm-stamps" div.
var div = document.getElementById('ukkonen-visualization');
var ukkonenVisualization = Elm.embed(Elm.UkkonenVisualization, div);
var treeGraph = document.getElementById('tree-graph');

ukkonenVisualization.ports.tree.subscribe(function(tree) {
treeGraph.innerHTML = tree;
});
</script>
</html>

0 comments on commit ca4ebae

Please sign in to comment.