Skip to content

hyoujeen/dijkstra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSC 212 - Programming with Data Structures
Professor John Ridgway
Written reflection for Final Project - Stage 2


You Jeen Ha
08 May 2018

        For the second stage of the CSC212 final project, I chose to (1) implement the Dijkstra Algorithm in a class of its own as well as (2) integrate this class into a GUI application. (The Graph interface has not been changed for my project. I changed my GraphImplementation class so that the runtime is more efficient for my methods, namely by replacing the lists with hashsets.) Both extensions can be tested by first running the files provided in my submission and, when the Graph Application window appears, first clicking on a cyan node and then the button "Find shortest distance." Once the button is pressed, the shortest distances from the clicked node to the other nodes appear at the top of the Graph Application window as text. In the text area, the user-selected node, the other nodes in the graph, and the shortest distances between them are specified. The shortest distances are based on the coordinate values of the nodes, so the distances printed are dynamic in that when the user drags the nodes to different positions, the distances change also, albeit the shortest distances still remain the shortest. After clicking on a node and seeing the shortest distances from the clicked node to the other nodes, the user can simply click on another node in the same window and then click the "Find shortest distance." button again to get the shortest distances for the newly clicked node. Yet, if the user wishes to clear the text at the top of the window, the user can click the "Reset" button to see an empty text area.
	To see if the distances printed are truly the shortest, one can add more edges in the GraphGUI.java file within the initializeGraph() method and click the "Find shortest distance" button to see if the application actually chooses the shortest path possible. For example, (as in the GraphGUI.java file included in my submission), if the graph has edges such that there are a path from node1 to node2 to node6 (total distance: 211) and a path from node1 to node3 to node6 (total distance: 252), when the user clicks on node1, the execution of the Dijkstra class will print the path from node1 to node2 to node6 in the window which has the shortest possible distance from node1 to node6. Moreover, when the user clicks on node3 and the graph has a path from node3 to node1 to node2 to node6 (total distance: 352) as well as a path from node3 to node6 (total distance: 111), the execution of the Dijkstra class will print the shortest path from node3 to node6 in the window (the path with a total distance of 111). The functionality of the Dijkstra class can be further tested by creating/removing/rearranging nodes and edges in this manner within the GraphGUI class, in the initializeGraph() method.
	Evidently, the shortest distance between the user-selected node and itself is always 0 according to the Dijkstra Algorithm, and this truth is reflected in the distances printed in the Graph Application window. However, if there is no directed path between a clicked node and another node in the graph, the distance printed will be a very large number (approximately 2147483647) that indicates infinity or, in other words, that there is no path between that clicked node and the other nodes in the graph. So, if, for instance (as in the GraphGUI.java file in my submission), there are node4, node5, node6, and node7 in the graph which are all leaves of the graph, their distances to the other nodes in the graph is printed in the text area as approximately 2147483647. However, if one were to add an edge between node4 and node3, connecting the two nodes, then the shortest distances from node4 to the other nodes will accordingly change.
	As challenging as this final project was, it genuinely was a culmination of everything I learned during lecture, lab, and throughout the weeks as I completed the homework assignments. CSC212, difficult as it was, is a quite rewarding course, and I would like to thank Professor Ridgway for helping us get through the course material. Thank you for a fruitful semester!

About

Final Project for CSC 212 at Smith College

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages