Implemented Graph algorithms in c++ (Advance data structure)
O(N^2)
O(E)
to implement a graph.O(N+E)
O(E)
to implement a graph.E denotes the number of connections or edges.
N denotes the number of vertices.
void BFSvisit()
for the connected graph and void NotconnBFS()
for the not connected graph.red[]
will keep track of visited and not visited vertix till now during BFS and DFS run.predecessor[]
will keep track of the current visiting vertix parent in the BFS and DFS tree (will help to determine the shortest path location) pathlength[]
will keep track of the shortest disytance from the root vertix in the BFS tree.vertices[]
Original graphtransposevertices[]
Transpose graphrunvertix
the vertix from where i want to startO(N + E)
void DFSvisit()
start[]
to store the entry time of any vertix in the dfs treefinish[]
to store the recursion back tracking time for a node after deadend.heightvertix[]
to store the height or distance of a vertix from the root vertixTo check whether the graph has a cycle or not and determine all the cycles present in the Graph void DFScyclevisit()
(Using the concept of backedge by computeing start and finish time of a vertix )
To compute all the strongly connected components in the Graph void DFSforstronglyconnected()
Average case O(N + E)
minspantree[][3]
will store all the edges and weights of the edges in my minimum spanning tree so that i can approach to all the vertices in my graph with the minimum total weight.