Skip to contents

A scene pre-configured for graph theory visualizations. Provides methods for adding graphs, running algorithms, and highlighting paths.

Super class

manimR::Scene -> GraphScene

Public fields

graph

The main Graph object

Methods

Inherited methods


Method new()

Create a GraphScene

Usage

GraphScene$new(name = "graph_scene", ...)

Arguments

name

Scene name

...

Additional args


Method add_graph()

Add a graph to the scene

Usage

GraphScene$add_graph(vertices, edges, layout = "spring", directed = FALSE, ...)

Arguments

vertices

Vertex ids

edges

Edge list

layout

Layout algorithm

directed

Whether the graph is directed

...

Additional args for Graph/DiGraph

Returns

The Graph mobject


Method highlight_path()

Highlight a path in the graph

Usage

GraphScene$highlight_path(path, color = YELLOW, duration = 0.5)

Arguments

path

Vector of vertex ids forming the path

color

Highlight color

duration

Animation duration per edge


Method animate_bfs()

Animate BFS traversal

Usage

GraphScene$animate_bfs(start_vertex, color = YELLOW, duration = 0.3)

Arguments

start_vertex

Starting vertex id

color

Traversal highlight color

duration

Duration per vertex


Method clone()

The objects of this class are cloneable with this method.

Usage

GraphScene$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.