Skip to content

Commit 861247c

Browse files
committed
Preview slides for all chapters, Chapter 0 now has benchmarks, chapter 8 now also contains triangle centrality scenes and notebook.
1 parent ea427a9 commit 861247c

21 files changed

Lines changed: 1328 additions & 104 deletions

File tree

Chapter0/Scene0.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,28 @@ def construct(self):
4141

4242
# Fade out title and logos at the end
4343
self.play(FadeOut(title), FadeOut(logos_group), FadeOut(footer))
44+
45+
# Chapter summary slide
46+
with self.voiceover(
47+
"""In this chapter, we'll cover how sparse matrices represent graphs,
48+
the duality between graphs and matrices, the basics of matrix-vector
49+
multiplication, and why algebraic approaches to graph algorithms
50+
are so powerful."""
51+
):
52+
chapter_title = Text("Chapter 0: Introduction to GraphBLAS", font_size=40).to_edge(UP)
53+
54+
outline = VGroup(
55+
Text("Sparse matrices and graph representation", font_size=28),
56+
Text("Graph-matrix duality", font_size=28),
57+
Text("Matrix-vector multiplication basics", font_size=28),
58+
Text("Why algebraic graph algorithms", font_size=28),
59+
).arrange(DOWN, buff=0.4, aligned_edge=LEFT)
60+
outline.next_to(chapter_title, DOWN, buff=0.8)
61+
62+
self.play(Write(chapter_title))
63+
self.play(FadeIn(outline))
64+
self.wait(1)
65+
66+
# Fade out summary
67+
self.play(FadeOut(chapter_title), FadeOut(outline))
4468
self.wait(0.5)

Chapter0/Scene3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def construct(self):
102102
if value == 0:
103103
sparse_matrix.get_entries()[i * len(row) + j].set_opacity(0)
104104

105-
sparse_matrix.to_edge(LEFT, buff=0.5)
105+
sparse_matrix.to_edge(LEFT, buff=0.75)
106106
sparse_vector = Matrix(initial_result_data, v_buff=0.5).scale(1).next_to(sparse_matrix, RIGHT, buff=0.5)
107107

108108
for j, sparse_entry in enumerate(sparse_vector.get_entries()):

Chapter0/Scene4.py

Lines changed: 91 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22
sys.path.insert(0, '..')
3+
import math
34

45
from manim import *
56
from manim_voiceover import VoiceoverScene
@@ -8,58 +9,106 @@
89

910
from scene_utils import setup_scene
1011

11-
matrices = [
12-
('pct20stif', 'Structural Analysis', 1, 2),
13-
('rw5151', 'Statistics and Mathematics', 1, 5),
14-
('lpl1', 'Resource Optimization', 2, 4),
15-
('poli_large', 'Economic Planning', 1, 5),
16-
('conf5_0-4x4-10', 'Theoretical Quantum Chemistry', 1, 5),
17-
]
12+
13+
def get_chart_config(values):
14+
"""Return y_range, scale factor, and format function based on max value."""
15+
max_val = max(values)
16+
17+
if max_val >= 1.0: # Billions scale
18+
# Round up to nice number for y_max
19+
y_max = math.ceil(max_val * 1.2) # 20% headroom
20+
y_step = max(1, y_max // 4)
21+
scale = 1.0
22+
suffix = "B"
23+
else: # Millions scale (values are in billions, so 0.375 = 375M)
24+
# Convert to millions for display
25+
max_millions = max_val * 1000
26+
y_max_millions = math.ceil(max_millions / 100) * 100 # Round to nearest 100M
27+
y_max = y_max_millions / 1000 # Back to billions for chart
28+
y_step = y_max / 4
29+
scale = 1000 # Multiply by 1000 to get millions
30+
suffix = "M"
31+
32+
return y_max, y_step, scale, suffix
33+
34+
35+
def format_value(val, scale, suffix):
36+
"""Format value for bar label."""
37+
display_val = val * scale if scale > 1 else val
38+
if display_val >= 10:
39+
return f"{int(display_val)}{suffix}"
40+
else:
41+
return f"{display_val:.1f}{suffix}"
42+
43+
# Graph labels with edge counts
44+
GRAPHS = ["Twitter\n1.5B", "web\n1.9B", "kron\n4.2B", "urand\n4.3B"]
45+
46+
# Placeholder benchmark results (billions of edges/second)
47+
BENCHMARKS = {
48+
"Breadth First Search": [5.8, 7.1, 7.6, 5.0],
49+
"PageRank": [0.148, 0.337, 0.217, 0.375],
50+
"Connected Components": [1.2, 1.1, 1.1, 1.1],
51+
"Single Source Shortest Path": [0.181, 0.717, 0.257, 0.175],
52+
}
53+
54+
ALGORITHM_SUMMARIES = {
55+
"Breadth First Search": "BFS explores a graph level by level, traversing all nodes reachable from a starting node.",
56+
"PageRank": "PageRank computes the importance of each node based on the structure of incoming links.",
57+
"Connected Components": "Connected components identifies groups of nodes that are reachable from one another.",
58+
"Single Source Shortest Path": "SSSP finds the minimum cost path from a source node to all other nodes in a weighted graph.",
59+
}
1860

1961
class Scene4(VoiceoverScene, Scene):
2062
def construct(self):
2163
setup_scene(self)
2264

65+
title = Text("SuiteSparse GraphBLAS Performance", font_size=36).to_edge(UP)
66+
y_label = Text("Edges/Second", font_size=20).rotate(PI/2)
67+
2368
with self.voiceover(
24-
"""Sparse graphs and linear algebra play an important
25-
role in many scientific and engineering disciplines,
26-
including:"""
69+
"""SuiteSparse GraphBLAS achieves impressive performance across
70+
standard graph algorithm benchmarks on four large-scale graphs
71+
ranging from 1.5 to 4.3 billion edges."""
2772
):
28-
title = Tex("Graphs are Everywhere").scale(1.5).to_edge(UP)
2973
self.play(Write(title))
30-
self.wait(3)
3174

32-
for subdir, description, ai, gi in matrices:
33-
matrix_image = ImageMobject(f"../scraped_images/{subdir}/image_{ai}_inv.jpg").scale(1.5).to_edge(LEFT)
34-
graph_image = ImageMobject(f"../scraped_images/{subdir}/image_{gi}.jpg").scale(1.5).to_edge(RIGHT)
75+
for bench_name, values in BENCHMARKS.items():
76+
subtitle = Text(bench_name, font_size=28).next_to(title, DOWN)
3577

36-
self.play(FadeIn(matrix_image), FadeIn(graph_image))
37-
with self.voiceover(description):
38-
self.wait(2)
39-
self.play(FadeOut(matrix_image), FadeOut(graph_image))
78+
# Get dynamic y-axis configuration based on data scale
79+
y_max, y_step, scale, suffix = get_chart_config(values)
4080

41-
self.play(FadeOut(title))
81+
# Create chart with zero values initially
82+
chart = BarChart(
83+
values=[0, 0, 0, 0],
84+
bar_names=GRAPHS,
85+
y_range=[0, y_max, y_step],
86+
y_length=4,
87+
x_length=10,
88+
bar_colors=[BLUE, GREEN, ORANGE, RED],
89+
).scale(0.9)
4290

43-
with self.voiceover(
44-
"""In our next video, we will introduce the Python
45-
bindings for GraphBLAS and explore the duality between
46-
matrix multiplication and graph traversal in more
47-
depth. We will also introduce fundamental GraphBLAS
48-
concepts including semirings, accumulation, and
49-
masking."""
50-
):
51-
title = Tex("Coming Next").scale(1.5).to_edge(UP)
52-
53-
bullet_points = BulletedList(
54-
"Install Python library",
55-
"Matrix Multiplication as Breadth First Search.",
56-
"Using Semirings to perform combining operations.",
57-
"Accumulating results as you go.",
58-
"Masking or including only certain values.",
59-
font_size=36
60-
)
61-
bullet_points.next_to(title, DOWN, buff=0.5)
91+
y_label_copy = y_label.copy().next_to(chart, LEFT)
6292

63-
self.play(Write(title))
64-
self.play(FadeIn(bullet_points, shift=UP, lag_ratio=0.1))
65-
self.wait(3)
93+
with self.voiceover(f"Results for {bench_name}."):
94+
self.play(Write(subtitle))
95+
self.play(Create(chart), FadeIn(y_label_copy))
96+
# Animate bars growing from zero to actual values
97+
self.play(chart.animate.change_bar_values(values))
98+
99+
# Add value labels above each bar
100+
bar_labels = VGroup()
101+
for i, (bar, val) in enumerate(zip(chart.bars, values)):
102+
label = Text(format_value(val, scale, suffix), font_size=18)
103+
label.next_to(bar, UP, buff=0.1)
104+
bar_labels.add(label)
105+
self.play(FadeIn(bar_labels))
106+
self.wait(1)
107+
108+
with self.voiceover(ALGORITHM_SUMMARIES[bench_name]):
109+
self.wait(0.5) # Chart stays visible during voiceover
110+
111+
self.play(FadeOut(chart), FadeOut(subtitle), FadeOut(y_label_copy), FadeOut(bar_labels))
112+
113+
self.play(FadeOut(title))
114+
self.wait(0.5)

Chapter0/Scene5.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import sys
2+
sys.path.insert(0, '..')
3+
4+
from manim import *
5+
from manim_voiceover import VoiceoverScene
6+
from dotenv import load_dotenv
7+
load_dotenv()
8+
9+
from scene_utils import setup_scene
10+
11+
matrices = [
12+
('pct20stif', 'Structural Analysis', 1, 2),
13+
('rw5151', 'Statistics and Mathematics', 1, 5),
14+
('lpl1', 'Resource Optimization', 2, 4),
15+
('poli_large', 'Economic Planning', 1, 5),
16+
('conf5_0-4x4-10', 'Theoretical Quantum Chemistry', 1, 5),
17+
]
18+
19+
class Scene5(VoiceoverScene, Scene):
20+
def construct(self):
21+
setup_scene(self)
22+
23+
with self.voiceover(
24+
"""Sparse graphs and linear algebra play an important
25+
role in many scientific and engineering disciplines,
26+
including:"""
27+
):
28+
title = Tex("Graphs are Everywhere").scale(1.5).to_edge(UP)
29+
self.play(Write(title))
30+
self.wait(3)
31+
32+
for subdir, description, ai, gi in matrices:
33+
matrix_image = ImageMobject(f"../scraped_images/{subdir}/image_{ai}_inv.jpg").scale(1.5).to_edge(LEFT)
34+
graph_image = ImageMobject(f"../scraped_images/{subdir}/image_{gi}.jpg").scale(1.5).to_edge(RIGHT)
35+
36+
self.play(FadeIn(matrix_image), FadeIn(graph_image))
37+
with self.voiceover(description):
38+
self.wait(2)
39+
self.play(FadeOut(matrix_image), FadeOut(graph_image))
40+
41+
self.play(FadeOut(title))
42+
43+
with self.voiceover(
44+
"""In our next video, we will introduce the Python
45+
bindings for GraphBLAS and explore the duality between
46+
matrix multiplication and graph traversal in more
47+
depth. We will also introduce fundamental GraphBLAS
48+
concepts including semirings, accumulation, and
49+
masking."""
50+
):
51+
title = Tex("Coming Next").scale(1.5).to_edge(UP)
52+
53+
bullet_points = BulletedList(
54+
"Install Python library",
55+
"Matrix Multiplication as Breadth First Search.",
56+
"Using Semirings to perform combining operations.",
57+
"Accumulating results as you go.",
58+
"Masking or including only certain values.",
59+
font_size=36
60+
)
61+
bullet_points.next_to(title, DOWN, buff=0.5)
62+
63+
self.play(Write(title))
64+
self.play(FadeIn(bullet_points, shift=UP, lag_ratio=0.1))
65+
self.wait(3)

Chapter1/Scene0.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,27 @@ def construct(self):
5858

5959
# Fade out title and logos at the end
6060
self.play(FadeOut(title), FadeOut(logos_group), FadeOut(footer))
61+
62+
# Chapter summary slide
63+
with self.voiceover(
64+
"""This chapter covers installing the python-graphblas library,
65+
creating matrices and vectors, basic operations, and provides
66+
code examples that will be used throughout the rest of the series."""
67+
):
68+
chapter_title = Text("Chapter 1: Python GraphBLAS", font_size=40).to_edge(UP)
69+
70+
outline = VGroup(
71+
Text("Installing python-graphblas", font_size=28),
72+
Text("Creating matrices and vectors", font_size=28),
73+
Text("Basic operations", font_size=28),
74+
Text("Code examples throughout the series", font_size=28),
75+
).arrange(DOWN, buff=0.4, aligned_edge=LEFT)
76+
outline.next_to(chapter_title, DOWN, buff=0.8)
77+
78+
self.play(Write(chapter_title))
79+
self.play(FadeIn(outline))
80+
self.wait(1)
81+
82+
# Fade out summary
83+
self.play(FadeOut(chapter_title), FadeOut(outline))
6184
self.wait(0.5)

Chapter2/Scene0.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,27 @@ def construct(self):
5555

5656
# Fade out title and logos at the end
5757
self.play(FadeOut(title), FadeOut(logos_group), FadeOut(footer))
58+
59+
# Chapter summary slide
60+
with self.voiceover(
61+
"""We'll learn what a semiring is, explore plus-times for standard
62+
arithmetic, min-plus for tropical optimization, and any-pair for
63+
structural operations on graphs."""
64+
):
65+
chapter_title = Text("Chapter 2: Semirings", font_size=40).to_edge(UP)
66+
67+
outline = VGroup(
68+
Text("What is a semiring", font_size=28),
69+
Text("Plus-times (standard arithmetic)", font_size=28),
70+
Text("Min-plus (tropical semiring)", font_size=28),
71+
Text("Any-pair (structural operations)", font_size=28),
72+
).arrange(DOWN, buff=0.4, aligned_edge=LEFT)
73+
outline.next_to(chapter_title, DOWN, buff=0.8)
74+
75+
self.play(Write(chapter_title))
76+
self.play(FadeIn(outline))
77+
self.wait(1)
78+
79+
# Fade out summary
80+
self.play(FadeOut(chapter_title), FadeOut(outline))
5881
self.wait(0.5)

Chapter3/Scene0.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,27 @@ def construct(self):
5757

5858
# Fade out title and logos at the end
5959
self.play(FadeOut(title), FadeOut(logos_group), FadeOut(footer))
60+
61+
# Chapter summary slide
62+
with self.voiceover(
63+
"""This chapter covers vector-matrix multiply, masking to control
64+
which outputs are written, complement masks for inverting selection,
65+
and replacement semantics for managing state between iterations."""
66+
):
67+
chapter_title = Text("Chapter 3: BFS Implementation", font_size=40).to_edge(UP)
68+
69+
outline = VGroup(
70+
Text("Vector-matrix multiply (vxm)", font_size=28),
71+
Text("Masking to control output", font_size=28),
72+
Text("Complement masks", font_size=28),
73+
Text("Replacement semantics", font_size=28),
74+
).arrange(DOWN, buff=0.4, aligned_edge=LEFT)
75+
outline.next_to(chapter_title, DOWN, buff=0.8)
76+
77+
self.play(Write(chapter_title))
78+
self.play(FadeIn(outline))
79+
self.wait(1)
80+
81+
# Fade out summary
82+
self.play(FadeOut(chapter_title), FadeOut(outline))
6083
self.wait(0.5)

Chapter4/Scene0.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,27 @@ def construct(self):
3737

3838
# Fade out intro elements
3939
self.play(FadeOut(title), FadeOut(logos_group), FadeOut(footer))
40+
41+
# Chapter summary slide
42+
with self.voiceover(
43+
"""We'll explore multi-hop path discovery, how A squared finds
44+
two-hop neighbors, transitive closure, and using mxm with
45+
different semirings."""
46+
):
47+
chapter_title = Text("Chapter 4: Matrix-Matrix Multiplication", font_size=40).to_edge(UP)
48+
49+
outline = VGroup(
50+
Text("Multi-hop path discovery", font_size=28),
51+
Text("A squared finds 2-hop neighbors", font_size=28),
52+
Text("Transitive closure", font_size=28),
53+
Text("mxm with semirings", font_size=28),
54+
).arrange(DOWN, buff=0.4, aligned_edge=LEFT)
55+
outline.next_to(chapter_title, DOWN, buff=0.8)
56+
57+
self.play(Write(chapter_title))
58+
self.play(FadeIn(outline))
59+
self.wait(1)
60+
61+
# Fade out summary
62+
self.play(FadeOut(chapter_title), FadeOut(outline))
4063
self.wait(0.5)

Chapter5/Scene0.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,27 @@ def construct(self):
5959

6060
# Fade out title and logos at the end
6161
self.play(FadeOut(title), FadeOut(logos_group), FadeOut(footer))
62+
63+
# Chapter summary slide
64+
with self.voiceover(
65+
"""This chapter covers source and destination matrices, how
66+
S times D equals the adjacency matrix, multigraphs with parallel
67+
edges, and hypergraphs for complex relationships."""
68+
):
69+
chapter_title = Text("Chapter 5: Incidence Matrices", font_size=40).to_edge(UP)
70+
71+
outline = VGroup(
72+
Text("Source and destination matrices", font_size=28),
73+
Text("S x D = Adjacency", font_size=28),
74+
Text("Multigraphs (parallel edges)", font_size=28),
75+
Text("Hypergraphs", font_size=28),
76+
).arrange(DOWN, buff=0.4, aligned_edge=LEFT)
77+
outline.next_to(chapter_title, DOWN, buff=0.8)
78+
79+
self.play(Write(chapter_title))
80+
self.play(FadeIn(outline))
81+
self.wait(1)
82+
83+
# Fade out summary
84+
self.play(FadeOut(chapter_title), FadeOut(outline))
6285
self.wait(0.5)

0 commit comments

Comments
 (0)