Docsity

Volcano! M4: Creating and Manipulating Graphs with Java, Study notes of Computer Science

Toggle sidebar
bg1
Volcano!! M4 Document
Devin Hunt and John White
Candidate Classes
Graph
Node
Edge
GraphIO
Algorithm
BreadthFirstSearch
ShortestPath
MinimumSpanning Tree
MaxFlow
GraphConnectivity
GraphEditor
GraphComponentFactory
NodeComponent
EdgeComponent
Scenarios
Scenario: User Creates New Graph
A user runs the program. A new GraphEditor is made. The GraphEditor object creates a new
undirected Graph model which will be edited. The user is presented with a blank screen.
Scenario: User Toggles Between Directed and Undirected Mode
A user changes an undirected graph into a directed graph by clicking on a UI component. The
component then notifies the Graph object through the GraphEditor that it is now a directed
graph. The Graph object then updates all of its Edge references by notifying them that they are
now directed. The EdgeComponent updates itself based on the change from its reference
object (Edge). The current view is invalidated and the EdgeComponent displays its changes
through the graphic context.
Scenario: User Adds a Node to the Graph
A user clicks on the UI and the GraphEditor handles the input by sending a request for a
NodeComponent to the GraphComponentFactory. The GraphEditor tells the Graph object to
create a new Node. The Graph object keeps a reference to the Node and returns it to the
GraphEditor. The GraphEditor sends the reference of the Node object to the NodeComponent
object and the new NodeComponent is added to the dependency list of the new Node.
Scenario: User Removes Node from the Graph
pf3

Partial preview of the text

Download Volcano! M4: Creating and Manipulating Graphs with Java and more Study notes Computer Science in PDF only on Docsity!

Volcano!! M4 Document

Devin Hunt and John White

Candidate Classes

Graph Node Edge GraphIO Algorithm BreadthFirstSearch ShortestPath MinimumSpanning Tree MaxFlow GraphConnectivity GraphEditor GraphComponentFactory NodeComponent EdgeComponent

Scenarios

Scenario: User Creates New Graph

A user runs the program. A new GraphEditor is made. The GraphEditor object creates a new undirected Graph model which will be edited. The user is presented with a blank screen.

Scenario: User Toggles Between Directed and Undirected Mode

A user changes an undirected graph into a directed graph by clicking on a UI component. The component then notifies the Graph object through the GraphEditor that it is now a directed graph. The Graph object then updates all of its Edge references by notifying them that they are now directed. The EdgeComponent updates itself based on the change from its reference object (Edge). The current view is invalidated and the EdgeComponent displays its changes through the graphic context.

Scenario: User Adds a Node to the Graph

A user clicks on the UI and the GraphEditor handles the input by sending a request for a NodeComponent to the GraphComponentFactory. The GraphEditor tells the Graph object to create a new Node. The Graph object keeps a reference to the Node and returns it to the GraphEditor. The GraphEditor sends the reference of the Node object to the NodeComponent object and the new NodeComponent is added to the dependency list of the new Node.

Scenario: User Removes Node from the Graph

A user clicks on the UI and the GraphEditor handles the input by sending a message to the Graph object. The message tells the Graph object to remove the particular Node object. The Graph object tells the Node that it is removed and then dereferences it. The NodeComponent knows the Node is removed and then destroys itself and invalidates the view.

Scenario: User Adds Edge between two Nodes.

A user wishes to join two nodes (A and B) such that the edge represents a directed connection from B to A with a weight of 11. The user first mouses over the UI component that represents B. As she does so, the UI component gains some buttons around its representation. One is labeled โ€œAdd Edge.โ€ The user clicks and drags off this button and towards A. As she does so, a line is drawn between B and the mouse cursor. When the cursor is over A, A becomes highlighted, signaling a valid selection. The user releases the mouse button signaling the selection. In doing so, the GraphEditor requests a new EdgeComponent from the GraphComponentFactory. This new EdgeComponent is added to the component list and the view is invalidated. When the EdgeComponent is drawn to the the screen it will ask for the user to input it's weight and if it was directed. The user inserts โ€œ11โ€ into the text field and signals that the edge was directed. Once this is complete, a new Edge can be added the Graph. The Graph takes in the two nodes โ€“ A and B โ€“ and the edge weight as input. When the new edge is created, the GraphEditor receives an update message from the Graph model and updates the display to reflect the new edge.

Scenario: User Loads a Graph file, adds an edge, and then saves the Graph file.

The GraphEditor receives a request to load a graph data from a properly formated file. This request is accompanied by a string representation of the files location. The GraphEditor passes this request to a new instance of the GraphIO class. GraphIO then opens the file stream and begins to parse the file. In doing so multiple things will occur. First, GraphIO will create a new instance of Graph. GraphIO will also create multiple instances of Node which will be added to the new Graph. As the file describes associations between the Nodes, Edges will be made. Once the parsing is complete the GraphIO will return the new Graph object. Once the view has been updated to reflect the fresh Graph, the user adds a new edge. This is accomplished much in the same method as described above. Once the graph has been changed to the users liking, it is saved back to file. This is done by passing the Graph model to the instance of GraphIO. GraphIO then opens the file and begins to output the graph model using a standardized language. Once this is complete, the file is closed and the user is notified of the successful save.

Scenario: User Runs Shortest Path Algorithm on the Graph.

A user wishes to run the shortest path algorithm on the current Graph model. After selecting the algorithm, the user is prompted to select two nodes to run between. The selected NodeComponents reflect the nodes the user wishes to run between. Once the selection is complete, the GraphEditor creates an instance of the ShortestPathAlgorithm and then, using the information from the selected NodeComponents, passes in the two nodes along with the