Generate WORKING Manim code for Scene 1.

IMPLEMENTATION: Certainly! Below is a detailed **plan implementation** for the scene following your strict positioning, object, animation, and cleanup requirements.

---

## Layout Plan

1. **Element 1:**  
   - Type: `Text`  
   - Position: `.to_edge(UP, buff=0.5)`  
   - Purpose: Title - "Shortest Path Problems & Dijkstra’s Algorithm"

2. **Element 2:**  
   - Type: `MathTex`  
   - Position: `.shift(UP * 1.5)`  
   - Purpose: Main equation/statement - "Find minimum total distance from start node to all others"

3. **Element 3:**  
   - Type: `Text`  
   - Position: `.shift(DOWN * 1.5)`  
   - Purpose: Secondary explanation - Real-world examples and brief intro to Dijkstra’s algorithm

4. **Element 4:**  
   - Type: Graph (Nodes and edges made from `Circle`, `Line`, `Dot`, `Text` for labels)  
   - Position: `.shift(LEFT * 2.5)`  
   - Purpose: Visual focus - simple weighted graph with labeled nodes and edges

5. **Element 5:**  
   - Type: `Text`  
   - Position: `.shift(RIGHT * 2.5)`  
   - Purpose: Transition text - "Next: How Dijkstra’s algorithm solves this step-by-step"

---

## Animation Sequence

### Step 1: Show Title  
- Action: `Write`  
- Element: Title Text ("Shortest Path Problems & Dijkstra’s Algorithm")  
- Duration: 2 seconds  
- Cleanup: None (keep title visible)

---

### Step 2: Show Main Equation (Concept Statement)  
- Action: `Write`  
- Element: MathTex ("Find minimum total distance from start node to all others")  
- Duration: 3 seconds  
- Cleanup: None (keep title and main equation visible)

---

### Step 3: Show Visual Graph and Secondary Text (Examples + Intro)  
- Action:  
  - `Create` the graph on left side  
  - `Write` the secondary text on lower center  
- Elements:  
  - Graph (circles, lines, dots, labels) shifted LEFT * 2.5  
  - Secondary Text ("Examples: road maps, network routing. Dijkstra’s algorithm is a systematic method...") shifted DOWN * 1.5  
- Duration: 4 seconds  
- Cleanup:  
  - FadeOut secondary text after showing  
  - Keep title, main equation, and graph visible

---

### Step 4: Show Transition Text on Right, Prepare for Next Scene  
- Action: `Write`  
- Element: Transition Text ("Next: How Dijkstra’s algorithm solves this step-by-step") shifted RIGHT * 2.5  
- Duration: 3 seconds  
- Cleanup:  
  - FadeOut graph and transition text  
  - FadeOut main equation and title (final cleanup)

---

## Detailed Object Descriptions (for clarity)

- **Title Text:**  
  `Text("Shortest Path Problems & Dijkstra’s Algorithm").to_edge(UP, buff=0.5).set_color(WHITE)`

- **Main Equation:**  
  `MathTex(r"\text{Find minimum total distance from start node to all others}").shift(UP * 1.5).set_color(YELLOW)`

- **Secondary Text:**  
  `Text("Examples: road maps, network routing.\nDijkstra’s algorithm is a systematic method...").shift(DOWN * 1.5).set_color(GREEN)`

- **Graph:**  
  - Nodes: `Circle(radius=0.2, color=BLUE)` + `Dot()` + `Text("A").next_to(nodeA, DOWN)` etc.  
  - Edges: `Line(start, end)` with `Text("3")` for weights near edges  
  - Positioned `.shift(LEFT * 2.5)`  
  - Use only BLUE, RED, GREEN, YELLOW, WHITE for colors

- **Transition Text:**  
  `Text("Next: How Dijkstra’s algorithm solves this step-by-step").shift(RIGHT * 2.5).set_color(RED)`

---

## Summary

| Step | Action           | Element(s)                      | Duration | Cleanup                         |
|-------|------------------|--------------------------------|----------|--------------------------------|
| 1     | Write            | Title                          | 2 sec    | None                           |
| 2     | Write            | Main Equation                  | 3 sec    | None                           |
| 3     | Create + Write   | Graph (left), Secondary Text   | 4 sec    | FadeOut secondary text         |
| 4     | Write            | Transition Text (right)        | 3 sec    | FadeOut graph, transition text, main eq, title |

---

This plan strictly follows your positioning, object, animation, and color constraints, keeping the scene clear, focused, and ready for the next explanation of Dijkstra’s algorithm mechanics.
PATTERN: function_graph

CRITICAL CONSTRAINTS:
1. Use ONLY these objects: Text, MathTex, Axes, Circle, Rectangle, Line, Arrow, Dot, SurroundingRectangle, VGroup
2. Use ONLY these animations: Write, Create, FadeIn, FadeOut 
3. Use ONLY these colors (no quotes): BLUE, RED, GREEN, YELLOW, WHITE, ORANGE, PURPLE
4. NO undefined objects like VideoFile, Slider, ImageMobject
5. NO Unicode characters - use LaTeX: \sqrt{} not √, \pm not ±

POSITIONING REQUIREMENTS (CRITICAL):
- Each element MUST have unique position within screen bounds
- SAFE positions only: .to_edge(UP), .shift(UP*1.5), .shift(DOWN*1.5), .shift(LEFT*2.5), .shift(RIGHT*2.5)
- NO extreme shifts: avoid UP*3, DOWN*3, LEFT*4, RIGHT*4 (goes off-screen)
- NO overlapping: if one element uses .shift(UP*1.5), others must use different positions
- Test positions: Title=top, Main=upper center, Secondary=lower center, Sides=left/right

TEMPLATE TO ADAPT:

        # Title at top
        title = Text("{title}").scale(0.8).to_edge(UP, buff=0.5)
        
        # Axes positioned in lower area
        axes = Axes(
            x_range=[-3, 3, 1],
            y_range=[-2, 4, 1], 
            x_length=6,
            y_length=4,
            axis_config={{"color": BLUE}}
        ).shift(DOWN * 0.5)
        
        # Function plot
        function = axes.plot(lambda x: {function_expr}, color=RED)
        
        # Equation display
        equation = MathTex(r"{equation}").shift(UP * 1.5)
        
        # Animation sequence
        self.play(Write(title))
        self.wait(1)
        self.play(Write(equation))
        self.wait(1)
        self.play(Create(axes))
        self.wait(1)
        self.play(Create(function))
        self.wait(2)
                

Replace placeholders with scene-specific values and ensure working Manim code.

Generate complete Python code:
SMART POSITIONING REQUIREMENTS:
- Analyze the content TYPE first: equation, diagram, comparison, process
- Position based on content meaning, not just arbitrary rules
- Main subject (equation/diagram) should be CENTER or slightly UP
- Supporting text should be BELOW the main subject
- Comparisons should use LEFT/RIGHT positioning
- Sequential content should use TOP-to-BOTTOM flow
- NEVER fade out main content - only temporary highlights

CAREFULLY IMPLEMENT THIS