Generate WORKING Manim code for Scene 1.

IMPLEMENTATION: Certainly! Below is a detailed **plan implementation** for the scene following your strict requirements:

---

### Layout Plan:

1. **Element 1:**  
   **Text** - `.to_edge(UP, buff=0.5)` - Title: "Understanding Dijkstra’s Algorithm"

2. **Element 2:**  
   **Circle, Line, Dot, MathTex** (combined to form a simple weighted graph) - `.shift(LEFT * 2.5)` - Visual focus: Diagram of a simple weighted graph with nodes and edges labeled with distances.

3. **Element 3:**  
   **Text** - `.shift(DOWN * 1.5)` - Secondary text: Explanation of the purpose and importance of Dijkstra’s algorithm.

---

### Animation Sequence:

1. **Write** - Title Text - 2 seconds - No cleanup (keep title visible throughout)  
   *"Understanding Dijkstra’s Algorithm" appears at top edge.*

2. **Create** - Graph Diagram (Circles for nodes, Lines/Arrows for edges, MathTex for weights) - 3 seconds - No cleanup (keep graph visible)

3. **Write** - Secondary Text (Introductory explanation) - 4 seconds - FadeOut old secondary text if any (none yet)  
   *Text: "Dijkstra’s algorithm finds the shortest path from a starting node to all others in a weighted graph with non-negative edges."*

4. **FadeOut** - Secondary Text - 1.5 seconds - Keep title and graph visible

5. **Write** - Secondary Text (Real-world importance) - 4 seconds - FadeOut old secondary text  
   *Text: "Shortest paths are crucial in GPS navigation and network routing to optimize travel and data flow."*

6. **FadeOut** - Secondary Text - 1.5 seconds - Keep title and graph visible

7. **Write** - Secondary Text (Transition) - 3 seconds - FadeOut old secondary text  
   *Text: "Now that we know what the algorithm does, let’s explore how it works step-by-step."*

8. **FadeOut** - Secondary Text - 1.5 seconds - Final cleanup (keep title visible, fade out graph if desired or keep for next scene)

---

### Detailed Element Descriptions:

- **Title Text:**  
  ```python
  title = Text("Understanding Dijkstra’s Algorithm", color=WHITE).to_edge(UP, buff=0.5)
  ```

- **Graph Diagram:**  
  - Nodes: 4 Circles with Dots inside, labeled A, B, C, D (MathTex or Text)  
  - Edges: Lines or Arrows connecting nodes with MathTex labels for weights (e.g. 1, 3, 4, 2)  
  - Position entire graph shifted LEFT by 2.5 units

- **Secondary Texts:**  
  1. "Dijkstra’s algorithm finds the shortest path from a starting node to all others in a weighted graph with non-negative edges."  
  2. "Shortest paths are crucial in GPS navigation and network routing to optimize travel and data flow."  
  3. "Now that we know what the algorithm does, let’s explore how it works step-by-step."  
  All positioned `.shift(DOWN * 1.5)` (lower center)

---

### Example Pseudocode snippet for Manim (not full code, just structure):

```python
class DijkstraIntro(Scene):
    def construct(self):
        # Title
        title = Text("Understanding Dijkstra’s Algorithm", color=WHITE).to_edge(UP, buff=0.5)
        self.play(Write(title), run_time=2)

        # Graph nodes
        node_A = Circle(radius=0.3, color=BLUE).shift(LEFT*3 + UP*0.5)
        dot_A = Dot(node_A.get_center(), color=BLUE)
        label_A = Text("A", color=WHITE).next_to(node_A, DOWN, buff=0.1)

        node_B = Circle(radius=0.3, color=BLUE).shift(LEFT*1 + UP*1.5)
        dot_B = Dot(node_B.get_center(), color=BLUE)
        label_B = Text("B", color=WHITE).next_to(node_B, UP, buff=0.1)

        node_C = Circle(radius=0.3, color=BLUE).shift(LEFT*1 + DOWN*0.5)
        dot_C = Dot(node_C.get_center(), color=BLUE)
        label_C = Text("C", color=WHITE).next_to(node_C, DOWN, buff=0.1)

        node_D = Circle(radius=0.3, color=BLUE).shift(RIGHT*0.5 + UP*0.5)
        dot_D = Dot(node_D.get_center(), color=BLUE)
        label_D = Text("D", color=WHITE).next_to(node_D, UP, buff=0.1)

        # Edges with weights
        edge_AB = Line(node_A.get_center(), node_B.get_center(), color=WHITE)
        weight_AB = MathTex("1", color=YELLOW).move_to((node_A.get_center() + node_B.get_center())/2 + UP*0.2)

        edge_AC = Line(node_A.get_center(), node_C.get_center(), color=WHITE)
        weight_AC = MathTex("4", color=YELLOW).move_to((node_A.get_center() + node_C.get_center())/2 + DOWN*0.2)

        edge_BD = Line(node_B.get_center(), node_D.get_center(), color=WHITE)
        weight_BD = MathTex("2", color=YELLOW).move_to((node_B.get_center() + node_D.get_center())/2 + UP*0.2)

        edge_CD = Line(node_C.get_center(), node_D.get_center(), color=WHITE)
        weight_CD = MathTex("3", color=YELLOW).move_to((node_C.get_center() + node_D.get_center())/2 + DOWN*0.2)

        graph_group = VGroup(
            node_A, dot_A, label_A,
            node_B, dot_B, label_B,
            node_C, dot_C, label_C,
            node_D, dot_D, label_D,
            edge_AB, weight_AB,
            edge_AC, weight_AC,
            edge_BD, weight_BD,
            edge_CD, weight_CD
        ).shift(LEFT*2.5)

        self.play(Create(graph_group), run_time=3)

        # Secondary Text 1
        text1 = Text(
            "Dijkstra’s algorithm finds the shortest path from a starting node to all others\nin a weighted graph with non-negative edges.",
            color=WHITE
        ).shift(DOWN*1.5)
        self.play(Write(text1), run_time=4)

        self.play(FadeOut(text1), run_time=1.5)

        # Secondary Text 2
        text2 = Text(
            "Shortest paths are crucial in GPS navigation and network routing\n to optimize travel and data flow.",
            color=WHITE
        ).shift(DOWN*1.5)
        self.play(Write(text2), run_time=4)

        self.play(FadeOut(text2), run_time=1.5)

        # Secondary Text 3 (Transition)
        text3 = Text(
            "Now that we know what the algorithm does,\nlet’s explore how it works step-by-step.",
            color=WHITE
        ).shift(DOWN*1.5)
        self.play(Write(text3), run_time=3)

        self.play(FadeOut(text3), run_time=1.5)

        # Final cleanup if needed
        # self.play(FadeOut(graph_group))
```

---

### Summary:

- Title fixed at top edge, visible throughout.  
- Graph on left side, not too far left (shift LEFT 2.5).  
- Secondary text always at lower center (DOWN 1.5).  
- Use only allowed objects, animations, colors.  
- FadeOut secondary texts before showing new ones.  
- Keep main equation visible (here, title acts as main equation placeholder).  
- No shifts beyond +/-3, all elements within screen bounds.

---

Let me know if you want me to generate the full Manim code or adjust any part!
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