Skip to content

Commit

Permalink
mkdocs framework, invoke tasks for building scenes, chapters, thumbna…
Browse files Browse the repository at this point in the history
…ils, videos
  • Loading branch information
michelp committed Nov 4, 2024
1 parent 5003063 commit 6784b0d
Show file tree
Hide file tree
Showing 58 changed files with 650 additions and 50 deletions.
27 changes: 12 additions & 15 deletions Chapter0/Scene0.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,23 @@ def construct(self):
logos_group = Group(*logos).arrange_in_grid(rows=4, cols=6, buff=0.5)

# Title text
title = Tex("Introduction to the GraphBLAS").scale(1.5).to_edge(UP)
title = Tex("The Illustrated GraphBLAS").scale(1.5).to_edge(UP)

with self.voiceover(
"""Welcome to this introduction to the GraphBLAS Sparse Linear Algebra
API. In this video series, we’ll explore the basic concepts of
algebraic graph theory. By the end of this series, you will understand
how to create new sparse graph algorithms using algebraic operations
expressed with simple mathematical notation."""
API. In this video series, we’ll explore the basic
concepts of algebraic graph theory and how it can be used
to write portable graph algorithms on many different kinds
of hardware like CPUs and GPUs. By the end of this series,
you will understand how to create new parallel graph
algorithms using simple mathematical notation."""
):
self.play(Write(title), FadeIn(logos_group))
self.wait(2)

# Footer text
footer = Text(
"The GraphBLAS Forum"
).scale(0.5).to_edge(DOWN)

# Display the footer text
self.play(Write(footer))
self.wait(2)
self.wait(1)
footer = Text(
"The GraphBLAS Forum"
).scale(0.75).to_edge(DOWN)
self.play(Write(footer))

# Fade out title and logos at the end
self.play(FadeOut(title), FadeOut(logos_group), FadeOut(footer))
Expand Down
10 changes: 6 additions & 4 deletions Chapter0/Scene1.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import scipy.optimize
from manim import *
from manim_voiceover import VoiceoverScene
from manim_voiceover.services.gtts import GTTSService
Expand Down Expand Up @@ -27,9 +28,10 @@ def construct(self):

with self.voiceover(
"""This matrix starts with many values, but most of them are zero.
This is a sparse matrix. Sparse data is everywhere and it
presents unique computing challenges when using Linear
Algebra"""
This is a common feature of many problems where the data
set or the connections between the data are sparse. Sparse
data is everywhere and efficiently analyzing it presents
unique computing challenges."""
):
self.play(Write(dense_matrix), *[Write(label) for label in row_labels + col_labels])

Expand Down Expand Up @@ -78,7 +80,7 @@ def construct(self):
edge_config={"stroke_color": BLUE}
).scale(1.3)

self.play(graph.animate.to_edge(RIGHT).shift(UP * 0.5)) # Shift graph to the right and up by 0.5 units
self.play(Create(graph.to_edge(RIGHT).shift(UP * 0.5))) # Shift graph to the right and up by 0.5 units

edge_labels = VGroup()

Expand Down
20 changes: 17 additions & 3 deletions Chapter0/Scene2.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import scipy.optimize
from manim import *
from manim_voiceover import VoiceoverScene
from manim_voiceover.services.gtts import GTTSService
Expand All @@ -15,6 +16,7 @@ def construct(self):
[0, 0, 0, 0, 2, 0]
]

num_rows, num_cols = len(matrix_data), len(matrix_data[0])
vector_data = [[0], [0], [0], [2], [0], [0]] # Vertical vector
initial_result_data = [[0], [0], [0], [0], [4], [18]] # Example result vector

Expand Down Expand Up @@ -42,7 +44,15 @@ def construct(self):
multiplying a vector on the left, the vector is treated as
a scaling factor for each of the rows in the matrix."""
):
self.play(Write(expression_group))
row_labels = [Tex(str(i)) for i in range(num_rows)]
col_labels = [Tex(str(j)) for j in range(num_cols)]

for i, label in enumerate(row_labels):
label.next_to(row_vector.get_rows()[i], LEFT * 3)
for j, label in enumerate(col_labels):
label.next_to(dense_matrix.get_columns()[j], UP * 1.5)

self.play(Write(expression_group), *[Write(label) for label in row_labels + col_labels])
self.wait(0.5)

with self.voiceover(
Expand Down Expand Up @@ -85,7 +95,7 @@ def construct(self):
edge_config={"stroke_color": BLUE}
).scale(1.3)

self.play(FadeOut(expression_group))
self.play(FadeOut(expression_group), FadeOut(*row_labels), FadeOut(*col_labels))
with self.voiceover(
"""The GraphBLAS uses sparse data structures that efficiently store
only elements in the matrix that are present in the data.
Expand All @@ -112,7 +122,11 @@ def construct(self):
sparse_entry.set_opacity(0)

self.play(Create(graph.to_edge(RIGHT).shift(UP * 0.5)))
self.play(FadeIn(sparse_matrix), FadeIn(sparse_vector))
for i, label in enumerate(row_labels):
label.next_to(sparse_matrix.get_rows()[i], LEFT * 3)
for j, label in enumerate(col_labels):
label.next_to(sparse_matrix.get_columns()[j], UP * 1.5)
self.play(FadeIn(sparse_matrix), FadeIn(sparse_vector), FadeIn(*row_labels), FadeIn(*col_labels))

with self.voiceover(
""" The core concept of graph algebra is that every matrix can be seen
Expand Down
158 changes: 133 additions & 25 deletions Chapter0/Scene3.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,147 @@ def construct(self):
self.set_speech_service(GTTSService(lang="en"))

# Title text
title = Tex("Coming Next").scale(1.5).to_edge(UP)
title = Tex("Graphs are Everywhere").scale(1.5).to_edge(UP)

self.play(Write(title))
self.wait(1)

with self.voiceover(
"""In the next video in this series, we'll explore more ways to use
matrix multiplication to work with graphs, and explain the
notion of a semiring which can be used to compute many
different functions across the values of GraphBLAS
objects."""
"""Graphs are a powerful mathemetical structure that can model
ecosystems and food webs, social networks, financial transactions and
many other real world interconnected systems."""
):
self.play(Write(title))
self.wait(2)
# Nodes representing species in the ecosystem
nodes = [
"Grass", "Berries", "Insects", "Rabbits", "Squirrels",
"Mice", "Birds", "Snakes", "Foxes", "Hawks", "Owls"
]

# Display the first bullet point
bullet1 = Tex("- Matrix Multiplication: Using matrix operations to work with graphs").scale(0.8)
bullet1.next_to(title, DOWN * 2, aligned_edge=LEFT).to_edge(LEFT)
self.play(Write(bullet1))
self.wait(2)
# Edges representing realistic feeding relationships in a forest ecosystem
edges = [
("Grass", "Insects"), ("Grass", "Rabbits"),
("Grass", "Mice"), ("Berries", "Birds"), ("Berries", "Squirrels"),
("Insects", "Birds"), ("Insects", "Mice"), ("Birds", "Snakes"),
("Rabbits", "Foxes"), ("Squirrels", "Hawks"), ("Mice", "Snakes"),
("Mice", "Owls"), ("Snakes", "Hawks"), ("Birds", "Owls"),
("Rabbits", "Owls"), ("Foxes", "Owls")
]

# Create the graph
graph = Graph(nodes, edges, layout="spring", layout_scale=3,
)

# Display the graph
self.play(Create(graph.scale(0.75)))
self.wait(1)

labels = {}
for node in nodes:
label = Text(node, font_size=24).next_to(graph.vertices[node], UP, buff=0.1)
labels[node] = label
self.add(label) # Add label to the scene

self.wait(6)
# Fade out at the end
self.play(FadeOut(graph), FadeOut(*labels.values()))

with self.voiceover(
""" In technology, they underpin computer networks, linking devices across the internet."""
):
nodes = [
"New York", "Los Angeles", "Chicago", "Houston", "Phoenix",
"Philadelphia", "San Antonio", "San Diego", "Dallas", "San Jose",
"Austin", "Jacksonville", "Fort Worth", "Columbus", "Charlotte"
]

# Edges representing realistic network connections between cities
# These connections might represent major data routes or network backbones
edges = [
("New York", "Chicago"), ("New York", "Philadelphia"), ("New York", "Dallas"),
("Los Angeles", "Phoenix"), ("Los Angeles", "San Diego"), ("Los Angeles", "San Jose"),
("Chicago", "Dallas"), ("Chicago", "Houston"), ("Chicago", "Philadelphia"),
("Houston", "Dallas"), ("Phoenix", "San Antonio"), ("San Antonio", "Dallas"),
("San Diego", "San Jose"), ("Dallas", "Austin"), ("Dallas", "Fort Worth"),
("Austin", "San Antonio"), ("Jacksonville", "Charlotte"), ("Charlotte", "Columbus"),
("Philadelphia", "Jacksonville"), ("Columbus", "Chicago"), ("San Jose", "Austin"),
("Charlotte", "Dallas")
]

# Create the graph
graph = Graph(
nodes, edges,
layout="circular", layout_scale=3,
vertex_config={"radius": 0.2}
)

# Display the graph
self.play(Create(graph.scale(0.75)))
self.wait(1)

# Add labels to each node
labels = {}
for node in nodes:
label = Text(node, font_size=18).next_to(graph.vertices[node], DOWN, buff=0.1)
labels[node] = label
self.add(label) # Add label to the scene

# Display the second bullet point
bullet2 = Tex("- Semirings: A mathematical structure to compute functions").scale(0.8)
bullet2.next_to(bullet1, DOWN * 2, aligned_edge=LEFT).to_edge(LEFT)
self.play(Write(bullet2))
self.wait(2)

# Footer text
footer = Text(
"This video is brought to you by The GraphBLAS Forum and funded by NumFOCUS"
).scale(0.5).to_edge(DOWN)
# Fade out at the end
self.play(FadeOut(graph), *[FadeOut(label) for label in labels.values()])
self.wait(1)

with self.voiceover("""and power knowledge graphs that organize information for complex queries."""):
self.wait(5)

with self.voiceover(
"""In AI, graphs represent the interconnected layers of neural networks, allowing language models to process information efficiently."""
):
# Define the number of layers and nodes per layer
num_layers = 4
nodes_per_layer = 4

# Layer node positions
layer_positions = []
layer_spacing = 1.5 # Spacing between layers
node_spacing = 1 # Spacing between nodes in a layer

# Generate positions for each layer
for layer_index in range(num_layers):
layer_x = -5 + layer_index * layer_spacing
layer_positions.append([
(layer_x, y_pos, 0) for y_pos in range(-int(nodes_per_layer/2), int(nodes_per_layer/2))
])

# Create nodes and store them in a list
nodes = []
for layer_index, positions in enumerate(layer_positions):
layer_nodes = [
Dot(point=pos, radius=0.1, color=BLUE).shift(RIGHT * layer_index * layer_spacing) for pos in positions
]
nodes.append(layer_nodes)
# Animate the nodes appearing
self.play(*[Create(node) for node in layer_nodes])

edges = []
# Create edges (arrows) between each node in one layer to each node in the next layer
for layer_index in range(num_layers - 1):
for source_node in nodes[layer_index]:
for target_node in nodes[layer_index + 1]:
edge = Arrow(
start=source_node.get_center(), end=target_node.get_center(),
buff=0.1, stroke_width=1, color=GREY
)
edges.append(edge)
self.play(Create(edge), run_time=0.1)

self.wait(2)

# Display the footer text
self.play(Write(footer))
self.wait(2)
# Fade out the entire network at the end
self.play(
*[FadeOut(node) for layer in nodes for node in layer],
)

# Fade out all elements at the end
self.play(FadeOut(title), FadeOut(bullet1), FadeOut(bullet2), FadeOut(footer))
self.play(FadeOut(title), FadeOut(*edges))
self.wait(0.5)
73 changes: 73 additions & 0 deletions Chapter0/Scene4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
from manim import *
from manim_voiceover import VoiceoverScene
from manim_voiceover.services.gtts import GTTSService

class Scene4(VoiceoverScene, Scene):
def construct(self):
self.set_speech_service(GTTSService(lang="en"))

# Title
title = Text("Examples of Different Types of Networks").scale(0.8).to_edge(UP)
self.play(Write(title))

# Define the voiceover text and graphs
with self.voiceover("""
On the left, we see a small tree of predator-prey relationships, where each node
represents a species, and the edges represent feeding relationships. In the center,
we have a social network, where each node represents an individual, and edges represent
social connections. Notice the triangular connections, showing mutual friendships.
On the right, we see a flow of transactions, where each node is an entity, and directed
edges indicate money flowing from one entity to another.
"""):
nodes = ["Root", "Child1", "Child2", "Grandchild1", "Grandchild2", "Grandchild3", "Grandchild4"]
edges = [
("Root", "Child1"), ("Root", "Child2"),
("Child1", "Grandchild1"), ("Child1", "Grandchild2"),
("Child2", "Grandchild3"), ("Child2", "Grandchild4")
]

# Create the directed graph with a tree layout
tree_graph = Graph(
nodes, edges,
layout="tree", root_vertex="Root", layout_scale=2,
vertex_config={"radius": 0.5, "fill_color": BLUE},
labels={node: Text(node, font_size=18).scale(0.8) for node in nodes}
)

# Display the tree graph
self.play(Create(tree_graph.scale(0.8).to_edge(LEFT)))
self.wait(2)

# Social network graph with a triangle
social_nodes = ["Alice", "Bob", "Carol", "Dave"]
social_edges = [("Alice", "Bob"), ("Alice", "Carol"), ("Bob", "Carol"), ("Carol", "Dave")]
social_graph = DiGraph(
social_nodes, social_edges,
layout="spring", layout_scale=1.5,
vertex_config={"radius": 0.5, "fill_color": GREEN},
labels={node: Text(node, font_size=24) for node in social_nodes}
)

# Position and display social network graph
social_graph.next_to(tree_graph, RIGHT, buff=1)
self.play(Create(social_graph.scale(0.8)))
self.wait(2)

# Transaction flow graph
transaction_nodes = ["Criminal", "Entity2", "Entity3", "Bank"]
transaction_edges = [("Criminal", "Entity2"), ("Entity2", "Entity3"), ("Entity3", "Bank"), ("Bank", "Criminal")]
transaction_graph = DiGraph(
transaction_nodes, transaction_edges,
layout="circular", layout_scale=1.5,
vertex_config={"radius": 0.5, "fill_color": ORANGE},
labels={node: Text(node, font_size=24) for node in transaction_nodes}
)

# Position and display transaction graph
transaction_graph.next_to(social_graph, RIGHT, buff=1)
self.play(Create(transaction_graph.scale(0.8)))
self.wait(2)

# Fade out all elements at the end
self.play(FadeOut(tree_graph), FadeOut(social_graph), FadeOut(transaction_graph), FadeOut(title))
self.wait(0.5)
Loading

0 comments on commit 6784b0d

Please sign in to comment.