Advisors: Prof. Muli Safra Mr. Oded Schwartz Submitted By: Nilly Perry Noa Stutzen Yehuda Rajuan I.D - 34896183 I.D - 32862922 I.D - 33989138 1. THE REPRESENTATION OF A QUESTION AS A STRING In this application a question consists of 5 elements. 1. The drawing of the graph, which is created using a java applet and includes: - Vertices (including weighs and colors if defined) - Edges (including weighs and colors if defined) - Directed/undirected 2. The selected algorithm type 3. The selected question type 4. The selected value for n 5. The selected value for k All these data are processed and presented as a string of this format: directed (true/false);n;k;algorithm type;question type; id of s (-1 if not defined);id of t (-1 if not defined); number of vertices;vertex string; … ;vertex string; number of edges;edge string; … ;edge string; Example: true;0;2;1;1;-1.0 ;-1.0; 3;0.01,355.0,281.0,false,false,0,1;0.02,202.0,115.0,false,false,0,1;0.03,474.0,97.0,false,false,0,1; 2;0.02,0.01,204.0,122.0,358.0,280.0,false,false,true,0;0.02,0.03,202.0,113.0,474.0,100.0,false,false,true,0; This string represents the following graph: 2. USING THE APPLICATION ON “ADMIN” MODE: On “admin” mode the application is used to create new graphs and define new questions. The available options may be divided into two groups: 2.1 Options of the HTML page: Submit – after creating a graph and completing all of the necessary input, selecting the submit button will invoke the creation of a string representing the graph, and that string will be presented in the field “Graph String”. Import – when placing a string representing a graph in the “Graph String” field, selecting the import button will invoke the translation of the string to a graph drawing and its presentation in the applet window. Please note that choosing a new algorithm type for an imported graph should take place only after loading the graph, using the “import” button. New – selecting this button will ‘clean’ all data (the drawing of the graph as well as the algorithm type, question type, n and k) and enable the user to create a completely new graph. Combo box for an algorithm type: 1. I - Independent set is a subset of vertices in a graph G such that no two vertices are connected by an edge. 2. Clique - A k-clique of a graph G is a subgraph of k vertices such that every pair is connected by edges. 3. Find Cut - A cut in a graph is a partition of the vertices into two parts A and B. The size of the cut is the number of edges with one end in A and the other in B. 4. DS - A dominating set in a directed graph is a subset of vertices such that every vertex is either in the subset or adjacent to at least one vertex in the subset. 5. VC - A vertex cover in an undirected graph is a set of vertices such that every edge in the graph is adjacent to some vertex in the set. 6. Shortest Path - A path in a graph G is a finite sequence of edges in which any two consecutive edges are adjacent, the first edge should begin with the vertex s and the last edge should end with the vertex t. The cost of a path is the sum of the cost of its edges 7. Hamilton Cycle - A Hamilton Cycle in a graph is a finite sequence of edges in which any two consecutive edges are adjacent such that by walking through the edges we visit every vertex exactly once and return to the starting vertex. 8. TSP - A Traveling Salesperson problem is finding a finite sequence of edges in which any two consecutive edges are adjacent such that by walking through the edges we visit every vertex and return to the starting vertex. 9. Edge Cover - An edge cover is a subset of edges such that all vertices are covered by these edges. 10. Coloring ( K-Coloring) -The assignment of k colors to the vertices of an undirected graph, such that no two adjacent vertices have the same color. Combo box for a question type ☺Note that n and k are the parameters given by the user. IS: 1. find an independent set of size k 2. deduct up to n edges to create an IS of size k Clique: 1. find a clique of size k 2. add up to n edges to create a clique of size k Find Cut: 1.find a cut of size k in the graph 2. add up to n edges with specified capacity to create a k sized cut DS: 1.find a dominating set of size k 2.add up to n edges to create a dominating set of size k VC: 1.find a vertex cover of the graph of size/weight k 2. deduct up to n edges to create a vertex cover of weight k Shortest Path: 1. find the shortest path from s to t 2. change the weight of n edges to create a shortest path from s to t with size/weight k Hamilton Cycle: 1.find a Hamilton cycle in the graph 2. add up to n edges to create a Hamilton cycle TSP: 1.find a traveling salesman path so that the total weight of the cycle is k 2. add n edge(with weight) so that the total weight of the cycle is k Edge Cover: 1. find an edge cover of size k 2. add up to n edges to create an edge cover of size k Coloring: 1.find a k-coloring of the graph 2. deduct up to n edges to create a k-coloring of the graph 2.2 functions of the java applet: ☺Note: pressing each button will cause it to change color to orange n – a field to hold the number of edges to be added/removed in case of a ‘type 2’ question. In ‘type 1’ questions n will be automatically initialized to 0. k - a field to hold the size/weight of the requested set of vertices/edges. add vertex – after pressing this button each mouse click on the drawing panel will create a new vertex of which the center point is the point clicked. In case the weight field contains a value, the new vertex will be automatically weighted with the specified value. add edge – after pressing this button the user should draw a line starting at the desired start vertex and ending at the desired end vertex. In an undirected graph, the start vertex could be either one of the two edge’s vertices. In case the weight field contains a value, the new edge will be automatically weighted with the specified value. set weight – after pressing this button it is possible to set weight of an existing vertex or edge simply by clicking on it. Weight – when entering a value in this field, each added element will be automatically weighted with the specified value, and the weight of each existing element could be changed using the “set weight” button. erase vertex - after pressing this button each mouse click on an existing vertex will erase the vertex. In addition, all edges connected to that vertex will be erased. erase edge - after pressing this button each mouse click on the orange circle of an existing edge will erase the edge. directed/undirected – pressing this button will cause the graph to switch from directed to undirected and vice versa. move vertex - after pressing this button the user should click on an existing vertex and drag it to the new location. This action will also cause the connected edges to adjust to the location change. set S – after pressing this button the user should click on the desired vertex and it will be set as the S vertex. In case such a vertex already exists, only the last chosen vertex will be set as the S vertex. set T - after pressing this button the user should click on the desired vertex and it will be set as the T vertex. In case such a vertex already exists, only the last chosen vertex will be set as the T vertex. 3. USING THE APPLICATION ON “STUDENT” MODE: ☺Note: In order to present the requested question to the student this HTML file should be used as following: The specified graph string should be placed in the “Graph String” field and than the “import” button should be pressed in order to load the graph and present the question on the screen. On “student ” mode the application is used both to present a question to the student and get as input a solution given by the student. The available options may be divided into two groups: 3.1 Options of the HTML page: Submit – after completing the changes needed to solve the given, selecting the submit button will invoke the performance of a verification algorithm. For a graded student a true/false parameter will be kept. For “tirgul” a dialog box will be displayed, specifying the reason for algorithm failure in case the solution was wrong and a congratulating message in case the solution was accurate. Another Try: After pressing “submit” button, the button becomes disabled. In order to submit a new answer, the student must use the “Another Try” button. This button loads again the original question graph. Algorithm Reminder – after pressing this button a dialog box will be displayed presenting the definition of the relevant problem. 3.2 Functions of the java applet: Color - clicking on this button will create a color-chooser dialog. Paint after choosing a color and pressing this button, each click on a vertex will change its color to the desired one. Choose edge - after pressing this button, each mouse click on the orange circle of an existing edge will mark it as chosen. Another click will reverse the action. Choose vertex - after pressing this button, each click on a vertex will mark it as chosen. Another click will reverse the action. Set weight, weight , erase edge and add edge as described in the admin section. 4. PROJECT CLASSES - GENERAL DESCRIPTION GetGraphApplet.java: The Main Class which activates an applet that, either receives a string as input and displays the graph it represents, or serves as a graphic tool for drawing a graph (and creating a string representing it). The “GetGraphApplet “class uses the actionPanel class for controlling the buttons. The actionPanel holds a boolean parameter for each button which indicates whether the specific butoon was the last button pressed. When the mouse is clicked on the drawing panel, the “GetGraphApplet” class verifies, using the action panel functions, which of the parameters holds a “true” value (if at all), and activates the relevant ”drawPanel” function. The “drawPanel” is used to manage all visual aspects (drawing edges, vertices, weights etc.) . For saving the graph data the “GetGraphApplet” class uses the Graph class. Package GraphComponents The Graph.java class holds a vector of Edges and a vector of Vertices which contain elements of classes “Edge” and “Vertex” respectively, and the graph properties (such as directed/undirected). Dealing with edges and vertices is done directly through the “Edge” and “Vertex” classes. Package Algorithms This package consists of 10 different classes (one for each algorithm), all of which inherit from the “AlgorithmCheck” class.
© Copyright 2026 Paperzz