This program allows you to create and manipulate a graph by adding and removing edges between vertices. It also provides the functionality to print the connections in the graph and checks for cycles whenever an edge is added.
- Clone the repository to your local machine.
- Compile the code using a C++ compiler.
- Execute the compiled program.
- Upon launching the program, you will be prompted to specify the number of vertices in the graph. The valid range for the number of vertices is between 1 and 50.
- After entering the number of vertices, a new graph will be initialized.
- You will be presented with a user guide that explains the available actions.
- Choose one of the following actions:
a
: Add an edge between two vertices.d
: Remove an edge between two vertices.p
: Print the connections in the graph.q
: Quit the program.
- Follow the prompts to provide the necessary information for each action.
- If an edge is added and a cycle is detected, the graph will terminate and print the final graph form.
- After each action, you will be prompted to choose another action until you decide to quit the program.
- If you wish to create a new graph, you can choose to do so after terminating the current graph.
<_###_> Initializing a new graph <_###_>
<_#_> Specify the number of vertices in this graph? <_#_>
# V >> 5
<_#_> User Guide <_#_>
> The index of vertices starts from 1 up to 5
> Input 'a' to add an edge between 2 vertices
> Input 'd' to remove an edge between 2 vertices
> Input 'p' to print the connections in the graph
> Input 'q' to finish editing the graph
> The code checks for a cycle each time an edge is added
**********************
<> Choose Action <>
a: add_edge d: delete_edge q: quit p: print
action > a
Add edge
> from node >> 1
> to node >> 2
>> Adding edge <<
Cycle detected? >> NO
**********************
<> Choose Action <>
a: add_edge d: delete_edge q: quit p: print
action > p
Connections in the graph:
Vertex 1: [2]
Vertex 2: []
**********************
<> Choose Action <>
a: add_edge d: delete_edge q: quit p: print
action > q
!___TERMINATING GRAPH___!
<_#_> New Graph? <_#_>
1: yes / 0: no >> 1
Contributions to this project are welcome. If you find any issues or have suggestions for improvement, please feel free to submit a pull request.