d-Separation: Reading Independence from Graphs

A Systematic Algorithm for Testing Conditional Independence

Introduction: Why d-Separation?

The Problem

In Topic 3, we learned about conditional independence. But how do we systematically determine if two variables are conditionally independent just by looking at the graph?

d-Separation (directed separation) is a graphical algorithm that answers this question:

Given a Bayesian Network graph, can we determine if X ⊥ Y | Z without looking at the probabilities?

YES! We just need to apply 3 Simple Rules to the paths connecting the variables.

What You'll Learn
Rule 1: Chain
A → B → C
Rule 2: Fork
A ← B → C
Rule 3: Collider
A → B ← C

We will learn how each structure determines if a path is Blocked (Independent) or Active (Dependent).

1. The Three Rules of d-Separation

Any path between two variables can be broken down into these three basic structures.
For each rule, we ask: Is the path Blocked or Active?

Rule 1: The Chain Rule (A → B → C)

graph LR A[A] --> B[B] --> C[C] style A fill:#635bff,color:white style B fill:#ffc107,stroke:#333,stroke-width:2px style C fill:#32D583,color:white
Information flows through B
B is Unobserved
Path Active

Information flows from A to C.
A and C are Dependent.

B is Observed
Path Blocked

B blocks the flow.
A and C are Independent.

Rule 2: The Fork Rule (A ← B → C)

graph TD B[B] --> A[A] B --> C[C] style B fill:#ffc107,stroke:#333,stroke-width:2px style A fill:#635bff,color:white style C fill:#32D583,color:white
B is the Common Cause
B is Unobserved
Path Active

B causes both A and C.
A and C are Dependent.

B is Observed
Path Blocked

Known cause explains correlation.
A and C are Independent.

Rule 3: The Collider Rule (A → B ← C)

graph TD A[A] --> B[B] C[C] --> B style B fill:#ffc107,stroke:#333,stroke-width:2px style A fill:#635bff,color:white style C fill:#32D583,color:white
B is the Common Effect
⚠️ OPPOSITE LOGIC! Colliders work differently.
B is Unobserved
Path Blocked

Causes are independent.
A and C are Independent.

B (or descendant) Observed
Path Active

Explaining Away effect.
A and C are Dependent.

Quick Reference: Independence Rules
Rule Pattern Middle Node Status Result (Independence)
1. Chain
A → B → C
Linear Unobserved Dependent (Active)
Observed Independent (Blocked)
2. Fork
A ← B → C
Common Cause Unobserved Dependent (Active)
Observed Independent (Blocked)
3. Collider
A → B ← C
Common Effect Unobserved Independent (Blocked)
Observed Dependent (Active)

2. The d-Separation Algorithm (Step-by-Step)

Testing X ⊥ Y | Z

To determine if X and Y are conditionally independent given evidence set Z, we use the d-separation algorithm to check if all paths between X and Y are blocked.

The Algorithm (4 Steps)
Step 1: Find All Paths

Find all undirected paths between X and Y (ignore arrow directions for now). A path is a sequence of nodes connected by edges.

Step 2: Check Each Path

For each path, examine every triple of consecutive nodes:

  • Identify if it's a Chain, Fork, or Collider
  • Apply the appropriate blocking rule
Step 3: Determine Path Status

A path is BLOCKED if at least one triple in the path is blocked. A path is ACTIVE if all triples in the path are active.

Step 4: Final Decision

X and Y are d-separated (conditionally independent) if ALL paths are blocked.

  • ✓ If all paths blocked: X ⊥ Y | Z
  • ✗ If at least one path active: X and Y are dependent given Z
Key Principle

Think of paths as "information highways" between X and Y. Evidence (Z) acts like roadblocks. If all highways are blocked, no information flows between X and Y → they're independent given Z.

3. Worked Examples with Step-by-Step Analysis

Example 1: Simple Chain

Question: Is Smoking ⊥ LungCancer | Tar ?

graph LR
    S[Smoking]
    T[Tar Buildup]
    L[Lung Cancer]
    
    S --> T --> L
    
    style S fill:#635bff,stroke:#0a2540,stroke-width:3px,color:#fff
    style T fill:#ffc107,stroke:#0a2540,stroke-width:3px,color:#000
    style L fill:#dc3545,stroke:#0a2540,stroke-width:3px,color:#fff
                        
Step-by-Step Solution:
Step 1: Find Paths
Path: Smoking → Tar → LungCancer (only one path)
Step 2: Identify Structure
Triple: Smoking → Tar → LungCancer
This is a CHAIN (A → B → C)
Step 3: Apply Rule
Chain rule: Blocked if middle node (Tar) is observed
Evidence set Z = {Tar} → Tar is observed ✓
Result: Path is BLOCKED
Step 4: Conclusion
All paths (only one) are blocked
✓ YES: Smoking ⊥ LungCancer | Tar

Interpretation: Once we know the tar buildup level, smoking status doesn't add information about lung cancer risk — the effect of smoking is "mediated through" tar buildup.

Example 2: Fork with No Evidence

Question: Is Fever ⊥ Cough | {} (no evidence)?

graph TD
    I[Influenza]
    F[Fever]
    C[Cough]
    
    I --> F
    I --> C
    
    style I fill:#dc3545,stroke:#0a2540,stroke-width:3px,color:#fff
    style F fill:#ff6b6b,stroke:#0a2540,stroke-width:3px,color:#fff
    style C fill:#ffc107,stroke:#0a2540,stroke-width:3px,color:#000
                        
Step-by-Step Solution:
Step 1: Find Paths
Path: Fever ← Influenza → Cough (only one path)
Step 2: Identify Structure
Triple: Fever ← Influenza → Cough
This is a FORK (A ← B → C)
Step 3: Apply Rule
Fork rule: Blocked if common parent (Influenza) is observed
Evidence set Z = {} → Influenza is NOT observed ✗
Result: Path is ACTIVE
Step 4: Conclusion
At least one path (the only one) is active
✗ NO: Fever and Cough are DEPENDENT (not independent)

Interpretation: Without knowing if the patient has influenza, fever and cough are correlated — observing fever makes cough more likely because both are caused by the common disease.

Example 3: Collider (Explaining Away)

Question: Is Burglary ⊥ Earthquake | Alarm ?

graph TD
    B[Burglary]
    A[Alarm]
    E[Earthquake]
    
    B --> A
    E --> A
    
    style B fill:#dc3545,stroke:#0a2540,stroke-width:3px,color:#fff
    style A fill:#ffc107,stroke:#0a2540,stroke-width:3px,color:#000
    style E fill:#ff6b6b,stroke:#0a2540,stroke-width:3px,color:#fff
                        
Step-by-Step Solution:
Step 1: Find Paths
Path: Burglary → Alarm ← Earthquake (only one path)
Step 2: Identify Structure
Triple: Burglary → Alarm ← Earthquake
This is a COLLIDER (A → B ← C) ⚠️
Step 3: Apply Rule (OPPOSITE!)
Collider rule: Blocked if collider (Alarm) is NOT observed
Evidence set Z = {Alarm} → Alarm IS observed ✓
Result: Path is ACTIVE (opposite of chain/fork!)
Step 4: Conclusion
At least one path (the only one) is active
✗ NO: Burglary and Earthquake are DEPENDENT given Alarm

Explaining Away: When we observe the alarm is on, burglary and earthquake become dependent. If we learn there was an earthquake, it "explains" the alarm, making burglary less likely. This is counter-intuitive but crucial!

Example 4: Multiple Paths (Complex)

Question: Is A ⊥ F | {C, D} ?

graph TD
    A[A]
    B[B]
    C[C]
    D[D]
    E[E]
    F[F]
    
    A --> B
    B --> C
    A --> D
    D --> E
    E --> F
    C --> F
    
    style A fill:#635bff,stroke:#0a2540,stroke-width:3px,color:#fff
    style F fill:#32D583,stroke:#0a2540,stroke-width:3px,color:#fff
    style C fill:#ffc107,stroke:#0a2540,stroke-width:2px,color:#000
    style D fill:#ffc107,stroke:#0a2540,stroke-width:2px,color:#000
    style B fill:#00d4ff,stroke:#0a2540,stroke-width:2px,color:#fff
    style E fill:#00d4ff,stroke:#0a2540,stroke-width:2px,color:#fff
                        
Step-by-Step Solution:
Step 1: Find All Paths
Path 1: A → B → C → F
Path 2: A → D → E → F
Step 2: Check Path 1 (A → B → C → F)
• Triple A→B→C: Chain, C observed → BLOCKED
• Triple B→C→F: Chain, C observed → BLOCKED
Path 1 verdict: BLOCKED (at least one triple blocked)
Step 3: Check Path 2 (A → D → E → F)
• Triple A→D→E: Chain, D observed → BLOCKED
• Triple D→E→F: Chain, D observed at start → Still checking...
Path 2 verdict: BLOCKED (first triple already blocked it)
Step 4: Conclusion
Both paths are blocked
✓ YES: A ⊥ F | {C, D}

Key Lesson: With multiple paths, we must check ALL of them. If even ONE path is active, the variables are dependent. Here, both C and D block their respective paths, so A and F are independent given {C, D}.

4. Interactive: Test Your Understanding

Burglary-Alarm Network: d-Separation Quiz

Test different evidence sets and see if variables are d-separated

graph TD
    B[🚨 Burglary
B] E[🌍 Earthquake
E] A[🔔 Alarm
A] J[📞 JohnCalls
J] M[📞 MaryCalls
M] B --> A E --> A A --> J A --> M style B fill:#635bff,stroke:#0a2540,stroke-width:2px,color:#fff style E fill:#635bff,stroke:#0a2540,stroke-width:2px,color:#fff style A fill:#ffc107,stroke:#0a2540,stroke-width:2px,color:#000 style J fill:#32D583,stroke:#0a2540,stroke-width:2px,color:#fff style M fill:#32D583,stroke:#0a2540,stroke-width:2px,color:#fff
Try These Test Cases:
  • B ⊥ E | {} (no evidence) — Should be independent (no path)
  • B ⊥ E | {A} — Should be DEPENDENT (collider activated!)
  • J ⊥ M | {A} — Should be independent (common parent observed)
  • J ⊥ M | {} — Should be DEPENDENT (common parent not observed)
  • B ⊥ J | {A} — Should be independent (chain blocked)
  • B ⊥ J | {} — Should be DEPENDENT (chain active)

Summary & Key Takeaways

What We Learned
  1. Three structures: Chain, Fork, Collider
  2. Blocking rules: Chain/Fork block when observed, Collider opposite
  3. d-Separation algorithm: Find paths, check triples, determine status
  4. Systematic reasoning: Step-by-step chain of thought
  5. Graph-based test: No probabilities needed!
Critical Points
  • Collider is opposite: Naturally blocked, active when observed
  • All paths matter: Even one active path → dependent
  • Descendants count: Observing collider's descendant also activates
  • Undirected paths: Ignore arrow direction when finding paths
  • Triple-by-triple: Check every consecutive triple in path
The Power of d-Separation

d-Separation is a purely graphical test for conditional independence.
No probabilities, no calculations — just graph structure!
This makes it incredibly powerful for analyzing BN properties and designing efficient inference algorithms.