Session23 Graphs II
Session23 Graphs II
Wrong!
GRAPHS WITH NEGATIVE WEIGHTS
Strongly Connected
Components:
Maximal set of vertices such that
for every pair of vertices u and v,
both are reachable from each
other.
CYCLE DETECTION: DEPTH-FIRST
SEARCH TO THE RESCUE
D
C
A
E
B D
https://visualgo.net/en/
dfsbfs
So….?
𝑂 (𝑛+ 𝑚)
Remember: n is the number of vertices (|V|) and m the number of
edges (|E|)
We must traverse all vertices, and all edges present in the graph.
CYCLE DETECTION
• pov
• poryv
• posryv
• psryv