Structural Graph Coverage · Week 2
Ek test path kisi sub-path ko "tour" kaise karta hai — seedhe, ghoom ke (sidetrip), ya raasta badalke (detour). Isi question ka poora breakdown.
N = {1,2,3,4,5,6,7} · start 1 · final 7 (double circle).
Loops: chhota loop 2⇄3, aur bada loop 1→2→4→6→1. Isliye graph cyclic hai.
Buttons dabao — graph pe sidetrip aur detour highlight ho jayenge.
Maano hume ek sub-path q ko test path p ke andar "cover" (tour) karna hai. 3 tareeke:
p me q hu-ba-hu, lagataar (contiguous) aata ho. Beech me koi ghumaav nahi.
Rule: q, p ka seedha subpath ho. Sabse strict.
p, q ke beech se ghoom ke wapas usi node pe aa sakta hai, phir aage badhta hai. Ghumaav = sidetrip.
Rule: q ki har EDGE p me same order me maujood ho. Sidetrip usi node pe return karta hai jahan se nikla.
p, q ke ek node se nikal ke agle node pe (dusre raaste se) pahunch jaye — beech wali edge chhod ke. Ghumaav = detour.
Rule: q ke har NODE p me same order me maujood ho. Detour agle node pe return karta hai (ek edge skip). Sabse lenient.
🔑 Asli farak — return kahan hota hai:
Sidetrip → node X se nikla, wapas X pe (same node). q ki saari edges bachi rehti hain ✓
Detour → node X se nikla, wapas agle node Y pe. Edge X→Y skip ho jaati hai ✗
| Cheez | Sidetrip | Detour |
|---|---|---|
| Kya match hona chahiye | q ki har edge | q ka har node |
| Ghumaav kahan return karta | Usi node pe (same) | Agle node pe (next) |
| q ki edges bachti hain? | Haan, saari ✓ | Nahi, ek edge skip ✗ |
| Kitna strict | Zyada strict | Zyada lenient |
Order of strength: Direct (strictest) ⊃ Sidetrip ⊃ Detour (loosest). Jo sidetrip se tour hota hai wo detour se bhi hota hai — ulta zaroori nahi.
Dono valid paths hain (har jodi ek real edge hai). Ab options check karte hain.
Claim: P tours sub-path [3,2,4,5,6] with the sidetrip [4,6,1,2,4].
q ki edges 3→2, 2→4, 4→5, 5→6 saari P me order me hain. Bas node 4 pe pahunch ke P ek chakkar lagata hai 4→6→1→2→4 aur wapas usi node 4 pe aa jaata hai — yahi valid sidetrip hai. ✓
Claim: P tours [3,2,4,5,6] with the sidetrip [4,5,6,1,2].
Sidetrip ko usi node pe wapas aana zaroori hai. [4,5,6,1,2] node 4 se shuru hoke node 2 pe khatam hota hai — same node nahi! Isliye ye sidetrip ho hi nahi sakta. (Sahi sidetrip [4,6,1,2,4] tha.) ✗
Claim: Q tours [1,2,4,6,1,7] with the detour [3,2,4,6].
Q = [1,2,4,5,6,1,7] — isme node 3 aata hi nahi. Toh [3,2,4,6] wala detour Q me exist hi nahi karta. Impossible. ✗
Claim: Q tours sub-path [1,2,4,6,1,7] with the detour [4,5,6].
q chahta hai edge 4→6, par Q direct 4→6 kabhi nahi jaata — wo 4→5→6 se pahunchta hai. Yani node 4 se nikal ke agle node 6 pe (ek edge skip karke) aa gaya. Yahi detour [4,5,6] hai. q ke saare nodes order me hain, isliye tour valid. ✓
Ye sidetrip kyun nahi? Kyunki edge 4→6 Q me hai hi nahi — yani "saari edges present" wali sidetrip-condition fail hoti hai. Sirf nodes present hain → detour.
➊ Direct tour — q seedha p ke andar (contiguous). Strictest.
➋ Sidetrip — har EDGE of q present · ghumaav same node pe return · [4,6,1,2,4] (4 se 4).
➌ Detour — har NODE of q present · ghumaav agle node pe return, ek edge skip · [4,5,6] (4 se 6).
Test trick: pehle dekho ghumaav kahan return karta hai — same node → sidetrip, next node → detour.
Final answer: A aur D sahi hain.
Structural graph coverage · tour / sidetrip / detour · self-study explainer