- Matanel Ohayon - https://github.com/Matanel1995
- Roey Finegold - https://github.com/RF555
This project is about ֿimplementing and presenting graphs.
This project splits into 2 parts.
implementation of directed graphs and algorithms on those graphs
for example : Shortest path between 2 vertices, find center of the graph and more.
implementation of GUI
in the GUI the user will be able to see the graph and change it or run function on the graph
for example the user can load graphs from JSON files save graphs to JSON files
and run all the functions that was implemented in part one.
All the functions and edits can be done by the menu bar
At each function or edit new window will popped up asking the user for the necessary details
At the bottom of the screen there is label with all the information about the results.
This is how the GUI look like:
for example let assume the user chose to find the shortest path between 2 vertices, new window will pop up and ask for the 2 vertices
| Function name | Explanation |
|---|---|
| getNode(int key) | returns the node_data by the node_id |
| EdgeData getEdge(int src, int dest) | eturns the data of the edge (src,dest), null if none |
| void addNode(NodeData n) | adds a new node to the graph with the given node_data |
| void connect(int src, int dest, double w) | Connects an edge with weight w between node src to node dest |
| Iterator nodeIter() | returns an Iterator for all the nodes in this graph |
| Iterator edgeIter() | returns an Iterator for all the edges in this graph |
| Iterator edgeIter(int node_id) | returns an Iterator for edges getting out of the given node |
| NodeData removeNode(int key) | Deletes the node (with the given ID) from the graph |
| EdgeData removeEdge(int src, int dest) | Deletes the edge from the graph |
| int nodeSize() | Returns the number of vertices (nodes) in the graph |
| int edgeSize() | Returns the number of edges |
| Function name | Explanation |
|---|---|
| void init(DirectedWeightedGraph g) | Inits the graph on which this set of algorithms operates on |
| DirectedWeightedGraph getGraph() | Returns the underlying graph of which this class works |
| DirectedWeightedGraph copy() | Computes a deep copy of this weighted graph |
| boolean isConnected() | Returns true if and only if (iff) there is a valid path from each node to each node |
| double shortestPathDist(int src, int dest) | Computes the length of the shortest path between src to dest |
| List shortestPath(int src, int dest) | Computes the the shortest path between src to dest - as an ordered List of nodes |
| NodeData center() | Finds the NodeData which minimizes the max distance to all the other nodes |
| List tsp(List cities) | Computes a list of consecutive nodes which go over all the nodes in cities |
| boolean save(String file) | Saves this weighted (directed) graph to the given |
| boolean load(String file) | loads a graph to this graph algorithm |
All the tests preformed on Intel i5-8250U 1.6Ghz CPU, and 8GB RAM 2400MHz
Download the project
Navigate to: Ex2>out>artifacts>Ex2_jar
Open the CMD in the this directory
Run this function:
java -jar Ex2.jar filePath
FilePath should be the full path to JSON file.