I made this Java program as an educational program that allows users to input commands in the command line interface (CLI) to generate and analyze graphs. The program offers two options: generating a random number of nodes graph or inputting a number of nodes. After selecting one of the options, the user can choose between computing the Minimum Spanning Tree (MST) of the graph, the shortest path between two input nodes using Dijkstra's algorithm, or to compute the BFS or DFS. Also, the user can choose to add new nodes or to connect existing ones with weighted edges.
The program uses the GraphStream library to visualize the graphs.
- Java 17 or higher
- Clone the repository.
- Import the project into your preferred Java IDE.
- Run the program in your IDE or from the command line.
- Follow the prompts to select a graph type and analysis method.
- If generating a graph with user input, enter the number of nodes when prompted.
- If analyzing shortest paths, enter two nodes to find the shortest path between them.
- If generating a BFS animation, enter the source node when prompted.
- If generating a DFS animation, enter the source node when prompted.
- If adding nodes or edges between nodes, follow the instructions as prompted.
- Template Method: The AbstractTemplateGenerator class defines the overall structure of the graph generation algorithm and delegates getSizeOfGraph hook method to be implemented by the subclasses.
- Union-Find: The UnionFind data structure is used for the MST calculation algorithm.
- Model-View-Controller (MVC): The program uses the MVC design pattern to separate concerns between the model (graph), user interface (CLI)/ controller (main program logic) and the view.
- Strategy: The program lets the user choose the type of generator at runtime through CLI.



