Graph¶
Qualified name: algan.mobs.manim\_compat.Graph
- class Graph(vertices, edges, labels=False, label_fill_color=ManimColor('#000000'), layout='spring', layout_scale=2, layout_config=None, vertex_type=<class 'algan.external_libraries.manim.mobject.geometry.arc.Dot'>, vertex_config=None, vertex_mobjects=None, edge_type=<class 'algan.external_libraries.manim.mobject.geometry.line.Line'>, partitions=None, root_vertex=None, edge_config=None)¶
Bases:
ManimCompatMobAn undirected graph (vertices connected with edges).
The graph comes with an updater which makes the edges stick to the vertices when moved around. See
DiGraphfor a version with directed edges.See also
GenericGraph- Parameters:
vertices (Sequence[Hashable]) – A list of vertices. Must be hashable elements.
edges (Sequence[tuple[Hashable, Hashable]]) – A list of edges, specified as tuples
(u, v)where bothuandvare vertices. The vertex order is irrelevant.labels (bool | dict) – Controls whether or not vertices are labeled. If
False(the default), the vertices are not labeled; ifTruethey are labeled using their names (as specified invertices) viaMathTex. Alternatively, custom labels can be specified by passing a dictionary whose keys are the vertices, and whose values are the corresponding vertex labels (rendered via, e.g.,TextorTex).label_fill_color (str) – Sets the fill color of the default labels generated when
labelsis set toTrue. Has no effect for other values oflabels.layout (LayoutName | dict[Hashable, Point3DLike] | LayoutFunction) – Either one of
"spring"(the default),"circular","kamada_kawai","planar","random","shell","spectral","spiral","tree", and"partite"for automatic vertex positioning usingnetworkx(see their documentation for more details), or a dictionary specifying a coordinate (value) for each vertex (key) for manual positioning.layout_config (dict | None) – Only for automatically generated layouts. A dictionary whose entries are passed as keyword arguments to the automatic layout algorithm specified via
layoutofnetworkx. Thetreelayout also accepts a special parametervertex_spacingpassed as a keyword argument inside thelayout_configdictionary. Passing a tuple(space_x, space_y)as this argument overrides the value oflayout_scaleand ensures that vertices are arranged in a way such that the centers of siblings in the same layer are at leastspace_xunits apart horizontally, and neighboring layers are spacedspace_yunits vertically.layout_scale (float | tuple[float, float, float]) – The scale of automatically generated layouts: the vertices will be arranged such that the coordinates are located within the interval
[-scale, scale]. Some layouts accept a tuple(scale_x, scale_y)causing the first coordinate to be in the interval[-scale_x, scale_x], and the second in[-scale_y, scale_y]. Default: 2.vertex_type (type[Mobject]) – The mobject class used for displaying vertices in the scene.
vertex_config (dict | None) – Either a dictionary containing keyword arguments to be passed to the class specified via
vertex_type, or a dictionary whose keys are the vertices, and whose values are dictionaries containing keyword arguments for the mobject related to the corresponding vertex.vertex_mobjects (dict | None) – A dictionary whose keys are the vertices, and whose values are mobjects to be used as vertices. Passing vertices here overrides all other configuration options for a vertex.
edge_type (type[Mobject]) – The mobject class used for displaying edges in the scene.
edge_config (dict | None) – Either a dictionary containing keyword arguments to be passed to the class specified via
edge_type, or a dictionary whose keys are the edges, and whose values are dictionaries containing keyword arguments for the mobject related to the corresponding edge.partitions (Sequence[Sequence[Hashable]] | None)
root_vertex (Hashable | None)
Methods
Attributes
animation_managerThis mob's scene-owned animation manager.
basisThe Mob's orientation and scale, as a flattened 3x3 matrix of shape
(*, 9).casts_shadowsWhether this Mob's geometry blocks light on its way from a light source to another surface -- whether it casts a shadow.
childrenThe Mobs attached below this one, in attachment order.
closed_shellWhether this Mob's triangles form a CLOSED shell -- every camera ray that enters the geometry crosses a second time on its way out.
draws_descendantsWhether
get_render_primitivesreturns geometry belonging to this Mob's DESCENDANTS as well as its own.forwardGet the direction the Mob is facing.
lifespanThis mob's [spawn, despawn) interval on its Scene timeline (a
Lifespan).locationThe Mob's position in world space, shape
(*, 3).normalized_basisThe Mob's orientation with scale divided out, shape
(*, 9).parentsThe Mobs this one is attached to, in attachment order.
receives_shadowsWhether this Mob's surfaces are darkened by shadows cast onto them.
rightGet the Mob's own rightward direction.
scale_coefficientThe Mob's scale along its own right, up and forward axes, shape
(*, 3).stroke_colorThe color of the circuit's border stroke.
two_sidedWhether this Mob's geometry should be lit from whichever side the ray arrives on.
upGet the Mob's own upward direction.
xThe Mob's x coordinate in world units, shape
(*, 1).xyThe Mob's x and y coordinates in world units, shape
(*, 2).yThe Mob's y coordinate in world units, shape
(*, 1).zThe Mob's z coordinate in world units, shape
(*, 1).z_indexWhich of two exactly coplanar circuits draws in front (higher wins).