Skip to content

Matanel1995/Ex2-OOP-Graph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ex2-OOP - Graphs

Made by:

Introduction:

This project is about ֿimplementing and presenting graphs.
This project splits into 2 parts.

Part one:

implementation of directed graphs and algorithms on those graphs
for example : Shortest path between 2 vertices, find center of the graph and more.

Part two:

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.

GUI:

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: Graph

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

popUp exemple

Supported functions

Directed graph:

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

Directed graph algorithms:

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

Algorithm time:

All the tests preformed on Intel i5-8250U 1.6Ghz CPU, and 8GB RAM 2400MHz times

How to run the program:

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.

how to run

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages