LAB-10 Flashcards
Connected Components CCs
ilands
Use flag visited and CC number
DFS backtracks but BFS don’t backtrack
Cycle Check - starts and ends at the same
Blue - explored
Orange - Visted
While - unvisited
In traversal . go in ascending order
Find what is topological sort?
can’t be done for undirected..
If you come across blue again in traversal then there is a cycle
Mark BLUE when you visit first. Mark as Orange when backtrack and no more paths.
zero in-degree. no incoming. Number of incoming are called in-degree
Explore Kahns method -> Topological sort (u should be smaller than v)
kahn’s algorithm for toposort
Kahn, delete edge and of no more incoming then duque that and enque next one onto queue
Use Graph for state modelling. Vertex is stage and edge is state transition. So, we can find any cyclic
In transport if price is different from A to B then it is directed as each direction has different price. If price is same then undirected
debrief