A Campus KioskA Campus KioskKendal Hershberger
& David Moses
Union University Scholarship Symposium
April 30, 2007
PurposePurpose
► Make an application to give directions to people new to campus who may not know their way around
► Make the application easily accessible
► Scalability
Choosing the LanguageChoosing the Language
► OpenGL using C Advantage - already familiar with the
language and graphics library Disadvantage - difficulty of drawing an
entire campus
►DirectX Disadvantage – Microsoft-specific systems
Choosing the LanguageChoosing the Language
► Flash and ActionScript Advantages
► Very accessible and easy to update► Opportunity to learn a new language► ActionScript has many similarites to Java and
other high-level languages► Easy drawing utilities
Disadvantages► Unfamiliar
ActionScriptActionScript
► scripting language behind Flash applications
►ActionScript 2.0 new object-oriented model
►Class-based, but classes defined in external .as file
Graph SearchingGraph Searching
►Graphs consist of nodes and vectors (or edges).
►A node can be connected to another node via an edge.
►For our case, the edges are paths that traverse Union's campus, and each node represents a geographical point where they connect or terminate.
Graph SearchingGraph Searching
►Example:
http://www.csie.ntu.edu.tw/~wcchen/algorithm/graph/Graph4.htmhttp://www.csie.ntu.edu.tw/~wcchen/algorithm/graph/Graph4.htm
Graph SearchingGraph Searching
►Depth Depth First Iterative
Deepening Best First
►Breadth Breadth First Uniform Cost Dijkstra's
Algorithm
►Problem: Find the best path from one node (one point on campus) to another node (another point on campus)
►Techniques:
Graph SearchingGraph Searching
►Depth First Go to a node, mark it as visited, push it on
a stack Go to a neighbour node, and do the same
thing If you’re at a dead end, pop the stack until
you find an unvisited neighbour Repeat until you’ve traversed the entire
tree (optimal path) or until you have found the destination node (non-optimal)
Graph SearchingGraph Searching
►Depth First
http://www.csie.ntu.edu.tw/~wcchen/algorithm/graph/Graph4.htmhttp://www.csie.ntu.edu.tw/~wcchen/algorithm/graph/Graph4.htm
Graph SearchingGraph Searching
►Iterative Deepening Same as Depth First, but depth of search
is controlled Better for very large graphs, still slow.
►Best First Greedy algorithm (not uninformed) that
simply selects the closest node to the destination
VERY fast, but can generate horrible paths under certain conditions
Graph SearchingGraph Searching
►Breadth First Go to a node, put all of its neighbour in a
queue Visit each neighbour in the order they
were placed, and put all of its neighbours in a queue
Continue until all nodes have been visited (optimal path) or until destination node is found (non-optimal path)
Graph SearchingGraph Searching
►Breadth First
http://www.csie.ntu.edu.tw/~wcchen/algorithm/graph/Graph4.htmhttp://www.csie.ntu.edu.tw/~wcchen/algorithm/graph/Graph4.htm
Graph SearchingGraph Searching
►Uniform Cost Same as Breadth First Search, but
prioritizes nodes that have shortest path from origin rather than simply the next node in the queue
More realistic paths, but still takes long
►Dijkstra's Algorithm Same as Uniform Cost, but actively keeps
track of shortest path to node Uses relaxation of the path cost Much faster than all others
Graph SearchingGraph Searching► dijkstra = function (origin:Node, destination:Node) {dijkstra = function (origin:Node, destination:Node) {
► var S:Array = new Array();var S:Array = new Array(); // list of visited nodes// list of visited nodes► var Q:Array = Node.getNodes(); var Q:Array = Node.getNodes(); // list of unvisited nodes// list of unvisited nodes► origin.dv = 0;origin.dv = 0; // initialize distance at origin to // initialize distance at origin to ►
► do {do {► var u:Node = extractMin(Q);var u:Node = extractMin(Q); // remove node with lowest // remove node with lowest
distancedistance► S.push(u);S.push(u); // mark it as visited// mark it as visited
► var neighbors:Array = u.getNeighbors();var neighbors:Array = u.getNeighbors(); // relax u's neighbors// relax u's neighbors► for (i=0; i<neighbors.length; i++) {for (i=0; i<neighbors.length; i++) {► var v:Node = neighbors[i];var v:Node = neighbors[i];► if (u.dv + u.getDistance(v) < v.dv) {if (u.dv + u.getDistance(v) < v.dv) {► v.dv = u.dv + u.getDistance(v);v.dv = u.dv + u.getDistance(v);► v.prevNode = u;v.prevNode = u;► }}► }}► } while (u != destination)} while (u != destination)► };};
Graph SearchingGraph Searching
►Dijkstra’s Algorithm
http://cgm.cs.mcgill.ca/~msuder/courses/203/lectures/greedy_algorithms/http://cgm.cs.mcgill.ca/~msuder/courses/203/lectures/greedy_algorithms/
Creating the Campus MapCreating the Campus Map
►Deciding on using an image or drawing the map ourselves
► Using Flash to draw graphics vector vs. raster graphics
► Quality► Scalability
Creating PathsCreating Paths
►Create a datatype to store the nodes and edges in ActionScript
►Make a list of points to place the nodes►Display it in a Flash scene
Creating PathsCreating Paths
►Kirupa’s Graph ADT►Node and Edge
classes var a:Node; a = new Node("a", 200, 50); a.addEdge(b, "a->b");
►Uses Depth First to find path
►Dynamically draws the path from origin to destination
Finding the Best PathFinding the Best Path
►Our implementation of the Graph ADT
►Tested using points around the Belltower area
►Depth First search is fairly accurate and fast
Finding the Best PathFinding the Best Path
►Completed entry of points for the rest of campus
►Our naïve Depth First search algorithm reveals its limitations
Finding the Best PathFinding the Best Path
►Switched from Kirupa’s Depth First Search and implemented our own Dijkstra’s algorithm in ActionScript
►Still needed to provide interface and integrate map with graph
Building an InterfaceBuilding an Interface
►Added map layer to Flash scene
►Started adding buttons and designing interface components
DebuggingDebugging
►Remaining Bugs Refresh problem
►Fixed by deleting the calls to draw.
Speed degradation►Caused by
unintended doubling of the graph size.
Faulty edges► Incorrect data entry…
over 500 individual edges!
Future PossibilitiesFuture Possibilities
►Interiors of buildings, including classrooms and faculty offices Zoom feature Database integration
►Touch screen kiosks located around campus
►Print feature