跳转至

网络

影片代码
import manimgx as m


class NetworksHero(m.Scene):
    def construct(self) -> None:
        vertices = [1, 2, 3, 4, 5, 6]
        edges = [(1, 2), (2, 3), (3, 1), (3, 4), (4, 5), (5, 6), (6, 4)]
        graph = m.Graph(vertices, edges, layout="spring", labels=True, layout_scale=3)
        self.play(m.Create(graph))
        self.play(graph.animate.change_layout("circular", layout_scale=3))
        self.wait()

网络是由边连接的顶点:即图论意义上的图。(关于函数的图形,请参见 绘图。)Graph 用线连接其顶点, DiGraph 用箭头连接,从每条边的第一个顶点指向第二个。两者都会自动为你 布局顶点(layout="spring"、"circular"、"tree"、…),或按你指定的位置放置;顶点默认 为圆点,除非你指定其他 mobject。

两者都能执行以下操作:添加和移除顶点与边、更改布局,以及从 NetworkX 读取网络。

Graph

代码
import manimgx as m


class GraphExample(m.Scene):
    def construct(self) -> None:
        vertices = [1, 2, 3, 4, 5, 6]
        edges = [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 1), (1, 4), (2, 5)]
        graph = m.Graph(
            vertices,
            edges,
            layout="circular",
            layout_scale=3,
            labels=True,
            vertex_config={1: {"fill_color": m.RED}},
            edge_config={(1, 4): {"stroke_color": m.YELLOW}},
        )
        self.play(m.Create(graph))
        self.play(graph[3].animate.move_to([0, 0, 0]))

无向图:由边连接的顶点,自动或手动布局; 除非另行设置,默认为白色圆点和线条。

每条边从一个顶点的中心到另一个顶点的中心,绘制在它们之后, 并随其移动而跟随。它接受 GenericGraph 的参数,后者列出了图所能做的事情。

m.Graph(vertices, edges, labels=False, label_fill_color=BLACK, layout='spring', layout_scale=2, layout_config=None, vertex_type=Dot, vertex_config=None, vertex_mobjects=None, edge_type=Line, partitions=None, root_vertex=None, edge_config=None)
源码

manimgx\mobjects\graph.py

def __init__(
    self,
    vertices: Sequence[V],
    edges: Sequence[Edge[V]],
    labels: bool | Mapping[V, Mobject] = False,
    label_fill_color: ParsableManimColor = BLACK,
    layout: Layout[V] = "spring",
    layout_scale: float | tuple[float, float, float] = 2,
    layout_config: Mapping[str, object] | None = None,
    vertex_type: Maker = Dot,
    vertex_config: Configs | None = None,
    vertex_mobjects: Mapping[V, Mobject] | None = None,
    edge_type: Maker = Line,
    partitions: Sequence[Sequence[V]] | None = None,
    root_vertex: V | None = None,
    edge_config: Configs | None = None,
) -> None:
    super().__init__()
    if isinstance(labels, Mapping):
        labels_by_vertex: dict[V, Mobject] = dict(labels)
    else:
        labels_by_vertex = (
            {v: MathTex(str(v), color=label_fill_color) for v in vertices}
            if labels
            else {}
        )
    if labels_by_vertex and vertex_type is Dot:
        vertex_type = LabeledDot
    self.default_vertex_config, own = _split(vertex_config, vertices)
    vertex_configs: dict[V, Config] = {
        v: own.get(v, copy(self.default_vertex_config)) for v in vertices
    }
    for v, label in labels_by_vertex.items():
        vertex_configs[v]["label"] = label
    self.vertices: dict[V, Mobject] = {
        v: _make(vertex_type, vertex_configs[v]) for v in vertices
    }
    """顶点的 mobject,按顶点索引。"""
    self.vertices.update(vertex_mobjects or {})
    self._place_vertices(
        edges,
        layout=layout,
        layout_scale=layout_scale,
        layout_config=layout_config,
        partitions=partitions,
        root_vertex=root_vertex,
    )
    self.default_edge_config, own_edges = _split(edge_config, edges)
    self._edge_config: dict[Edge[V], Config] = {
        e: own_edges.get(e, copy(self.default_edge_config)) for e in edges
    }
    self._populate_edge_dict(edges, edge_type)
    self.add(*self.vertices.values())
    self.add(*self.edges.values())
    self.add_updater(self.update_edges)

DiGraph

代码
import manimgx as m


class DiGraphExample(m.Scene):
    def construct(self) -> None:
        edge_config = {
            "stroke_width": 3,
            "tip_config": {"tip_length": 0.2, "tip_width": 0.2},
            (3, 4): {
                "color": m.RED,
                "tip_config": {"tip_shape": m.ArrowSquareTip},
            },
        }
        graph = m.DiGraph(
            [0, 1, 2, 3, 4],
            [(0, 1), (1, 2), (3, 2), (3, 4), (4, 0)],
            labels=True,
            layout="circular",
            layout_scale=3,
            edge_config=edge_config,
        )
        self.play(m.Create(graph))

有向图:由箭头连接的顶点,从每条边的第一个顶点 指向第二个顶点;除非另行设置,默认为白色圆点和箭头。

每条边从一个顶点的轮廓到另一个顶点的轮廓,末端为一个尖端, 由 edge_config 的 "tip_config" 塑形(参见 TipConfig),对所有边或某条边单独生效; 它随其顶点移动而跟随。它接受 GenericGraph 的参数,后者列出了图所能做的事情。

m.DiGraph(vertices, edges, labels=False, label_fill_color=BLACK, layout='spring', layout_scale=2, layout_config=None, vertex_type=Dot, vertex_config=None, vertex_mobjects=None, edge_type=Line, partitions=None, root_vertex=None, edge_config=None)
源码

manimgx\mobjects\graph.py

def __init__(
    self,
    vertices: Sequence[V],
    edges: Sequence[Edge[V]],
    labels: bool | Mapping[V, Mobject] = False,
    label_fill_color: ParsableManimColor = BLACK,
    layout: Layout[V] = "spring",
    layout_scale: float | tuple[float, float, float] = 2,
    layout_config: Mapping[str, object] | None = None,
    vertex_type: Maker = Dot,
    vertex_config: Configs | None = None,
    vertex_mobjects: Mapping[V, Mobject] | None = None,
    edge_type: Maker = Line,
    partitions: Sequence[Sequence[V]] | None = None,
    root_vertex: V | None = None,
    edge_config: Configs | None = None,
) -> None:
    super().__init__()
    if isinstance(labels, Mapping):
        labels_by_vertex: dict[V, Mobject] = dict(labels)
    else:
        labels_by_vertex = (
            {v: MathTex(str(v), color=label_fill_color) for v in vertices}
            if labels
            else {}
        )
    if labels_by_vertex and vertex_type is Dot:
        vertex_type = LabeledDot
    self.default_vertex_config, own = _split(vertex_config, vertices)
    vertex_configs: dict[V, Config] = {
        v: own.get(v, copy(self.default_vertex_config)) for v in vertices
    }
    for v, label in labels_by_vertex.items():
        vertex_configs[v]["label"] = label
    self.vertices: dict[V, Mobject] = {
        v: _make(vertex_type, vertex_configs[v]) for v in vertices
    }
    """顶点的 mobject,按顶点索引。"""
    self.vertices.update(vertex_mobjects or {})
    self._place_vertices(
        edges,
        layout=layout,
        layout_scale=layout_scale,
        layout_config=layout_config,
        partitions=partitions,
        root_vertex=root_vertex,
    )
    self.default_edge_config, own_edges = _split(edge_config, edges)
    self._edge_config: dict[Edge[V], Config] = {
        e: own_edges.get(e, copy(self.default_edge_config)) for e in edges
    }
    self._populate_edge_dict(edges, edge_type)
    self.add(*self.vertices.values())
    self.add(*self.edges.values())
    self.add_updater(self.update_edges)

TipConfig

DiGraph 边的尖端,在其 edge_config 中以 "tip_config" 给出:对所有边生效,或对某条边单独生效(参见 add_tip)。

tip_shape

尖端的类(默认 None: ArrowTriangleFilledTip)。

tip_length

尖端的长度,以场景单位计(默认 None:边的默认值)。

tip_width

默认填充三角形尖端的宽度,以场景单位计(默认 None: 其长度)。

tip_shape

尖端的类(默认 None: ArrowTriangleFilledTip)。

tip_length

尖端的长度,以场景单位计(默认 None:边的默认值)。

tip_width

默认填充三角形尖端的宽度,以场景单位计(默认 None: 其长度)。

网络能做什么

Graph 和 DiGraph 都继承自 GenericGraph,后者包含了它们的共有功能。

GenericGraph

vertices

顶点的 mobject,按顶点索引。

edges

边的 mobject,按顶点对索引。

add_vertices

代码
import manimgx as m


class GraphAddVerticesExample(m.Scene):
    def construct(self) -> None:
        graph = m.Graph(
            [1, 2, 3],
            [(1, 2), (2, 3)],
            layout={1: [-4, -1, 0], 2: [0, -2, 0], 3: [4, -1, 0]},
            vertex_config={"radius": 0.15},
        )
        self.add(graph)
        top = graph.add_vertices(
            4, positions={4: [0, 2.5, 0]}, vertex_config={"color": m.YELLOW}
        )
        self.play(m.FadeIn(top, scale=3))
        self.play(m.Create(graph.add_edges((1, 4), (3, 4))))

向图中添加顶点,不添加边。

每个顶点按图构造顶点的方式构造,使用覆盖图自身关键字的关键字, 并放置在其位置处,或图的中心处。图中已存在的顶点会引发 ValueError。

generic_graph.add_vertices(*vertices, **kwargs)
*vertices

新顶点:可哈希的值,每个是一个顶点的名称。

positions

新顶点所在之处,按顶点指定(默认 None:位于图的中心)。

labels

每个新顶点是否以其名称标注,名称以数学排版:True 表示 全部标注,或按顶点指定,True 或自定义标签(默认 False)。

label_fill_color

由名称生成的标签的颜色(默认黑色)。

vertex_type

新顶点的类(默认 Dot;带标签的为 LabeledDot)。

vertex_config

新顶点的关键字,覆盖图自身的:对所有顶点生效,以及某个顶点 在其名称下的独有配置,取代对所有顶点的配置(默认 None:无)。

vertex_mobjects

作为顶点本身的 Mobject,按顶点指定(默认 None:无)。

返回 由新顶点的 mobject 构成的新组。

源码

manimgx\mobjects\graph.py

def add_vertices(self, *vertices: V, **kwargs: Unpack[VertexOptions[V]]) -> Group:
    """向图中添加顶点,不添加边。

    每个顶点按图构造顶点的方式构造,使用覆盖图自身关键字的关键字,
    并放置在其位置处,或图的中心处。图中已存在的顶点会引发 ValueError。

    Args:
        *vertices: 新顶点:可哈希的值,每个是一个顶点的名称。
        **kwargs: [顶点关键字][manimgx.mobjects.graph.VertexOptions]:
            `positions`、`labels`、`vertex_type`、`vertex_config`,……。

    Returns:
        由新顶点的 mobject 构成的新组。

    Examples:
        ```python
        import manimgx as m


        class GraphAddVerticesExample(m.Scene):
            def construct(self) -> None:
                graph = m.Graph(
                    [1, 2, 3],
                    [(1, 2), (2, 3)],
                    layout={1: [-4, -1, 0], 2: [0, -2, 0], 3: [4, -1, 0]},
                    vertex_config={"radius": 0.15},
                )
                self.add(graph)
                top = graph.add_vertices(
                    4, positions={4: [0, 2.5, 0]}, vertex_config={"color": m.YELLOW}
                )
                self.play(m.FadeIn(top, scale=3))
                self.play(m.Create(graph.add_edges((1, 4), (3, 4))))
        ```
    """
    return Group(
        *(
            self._add_created_vertex(*v)
            for v in self._create_vertices(*vertices, **kwargs)
        )
    )

remove_vertices

代码
import manimgx as m


class GraphRemoveVerticesExample(m.Scene):
    def construct(self) -> None:
        graph = m.Graph(
            [1, 2, 3, 4, 5],
            [(1, 2), (2, 3), (3, 4), (4, 5), (5, 1), (1, 3)],
            layout="circular",
            layout_scale=3,
        )
        self.add(graph)
        self.play(m.FadeOut(graph.remove_vertices(3)))

从图中移除顶点,以及与之相连的边。

图中不存在的顶点会引发 ValueError。

generic_graph.remove_vertices(*vertices)
*vertices

要移除的顶点。

返回 由被移除的 mobject 构成的新组(对每个顶点,先为其边,再为顶点本身), 例如可用于淡出。

源码

manimgx\mobjects\graph.py

def remove_vertices(self, *vertices: V) -> Group:
    """从图中移除顶点,以及与之相连的边。

    图中不存在的顶点会引发 ValueError。

    Args:
        *vertices: 要移除的顶点。

    Returns:
        由被移除的 mobject 构成的新组(对每个顶点,先为其边,再为顶点本身),
        例如可用于淡出。

    Examples:
        ```python
        import manimgx as m


        class GraphRemoveVerticesExample(m.Scene):
            def construct(self) -> None:
                graph = m.Graph(
                    [1, 2, 3, 4, 5],
                    [(1, 2), (2, 3), (3, 4), (4, 5), (5, 1), (1, 3)],
                    layout="circular",
                    layout_scale=3,
                )
                self.add(graph)
                self.play(m.FadeOut(graph.remove_vertices(3)))
        ```
    """
    return Group(*(m for v in vertices for m in self._remove_vertex(v).submobjects))

add_edges

向图中添加边,以及边所引用而图中尚缺的顶点。

缺失的顶点先被添加,添加方式同 add_vertices,使用给定的 顶点关键字;随后每条边按图构造边的方式构造,使用覆盖图自身关键字的 边关键字。

generic_graph.add_edges(*edges, edge_type=Line, edge_config=None, **kwargs)
*edges

新边,每个是顶点的有序对。

edge_type

新边的类。

edge_config

新边的关键字,覆盖图自身的:对所有边生效,以及某条边 在其顶点对下的独有配置,取代对所有边的配置; None 表示无。

positions

新顶点所在之处,按顶点指定(默认 None:位于图的中心)。

labels

每个新顶点是否以其名称标注,名称以数学排版:True 表示 全部标注,或按顶点指定,True 或自定义标签(默认 False)。

label_fill_color

由名称生成的标签的颜色(默认黑色)。

vertex_type

新顶点的类(默认 Dot;带标签的为 LabeledDot)。

vertex_config

新顶点的关键字,覆盖图自身的:对所有顶点生效,以及某个顶点 在其名称下的独有配置,取代对所有顶点的配置(默认 None:无)。

vertex_mobjects

作为顶点本身的 Mobject,按顶点指定(默认 None:无)。

返回 由新 mobject 构成的新组,先为添加的顶点,再为边。

源码

manimgx\mobjects\graph.py

def add_edges(
    self,
    *edges: Edge[V],
    edge_type: Maker = Line,
    edge_config: Configs | None = None,
    **kwargs: Unpack[VertexOptions[V]],
) -> Group:
    """向图中添加边,以及边所引用而图中尚缺的顶点。

    缺失的顶点先被添加,添加方式同
    [add_vertices][manimgx.mobjects.graph.GenericGraph.add_vertices],使用给定的
    顶点关键字;随后每条边按图构造边的方式构造,使用覆盖图自身关键字的
    边关键字。

    Args:
        *edges: 新边,每个是顶点的有序对。
        edge_type: 新边的类。
        edge_config: 新边的关键字,覆盖图自身的:对所有边生效,以及某条边
            在其顶点对下的独有配置,取代对所有边的配置;
            None 表示无。
        **kwargs: 边所引用而图中尚缺的顶点的
            [顶点关键字][manimgx.mobjects.graph.VertexOptions]。

    Returns:
        由新 mobject 构成的新组,先为添加的顶点,再为边。
    """
    shared, own = _split(edge_config, edges)
    base = self.default_edge_config.copy() | shared
    new_vertices = [
        v for v in dict.fromkeys(it.chain(*edges)) if v not in self.vertices
    ]
    added = list(self.add_vertices(*new_vertices, **kwargs))
    for edge in edges:
        added.extend(
            self._add_edge(
                edge, edge_type=edge_type, edge_config=base | own.get(edge, {})
            )
        )
    return Group(*added)

remove_edges

从图中移除边,保留其顶点。

图中不存在的边会引发 ValueError。

generic_graph.remove_edges(*edges)
*edges

要移除的边,每个是顶点的有序对。

返回 由被移除的边的 mobject 构成的新组。

源码

manimgx\mobjects\graph.py

def remove_edges(self, *edges: Edge[V]) -> Group:
    """从图中移除边,保留其顶点。

    图中不存在的边会引发 ValueError。

    Args:
        *edges: 要移除的边,每个是顶点的有序对。

    Returns:
        由被移除的边的 mobject 构成的新组。
    """
    return Group(*(self._remove_edge(edge) for edge in edges))

change_layout

代码
import manimgx as m


class GraphChangeLayoutExample(m.Scene):
    def construct(self) -> None:
        graph = m.Graph(
            [1, 2, 3, 4, 5, 6],
            [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 1), (1, 4)],
            layout={v: [2 * v - 7, 0, 0] for v in range(1, 7)},
        )
        circle = graph.copy().change_layout("circular", layout_scale=3)
        self.add(graph)
        self.play(
            *(graph[v].animate.move_to(circle[v]) for v in graph.vertices)
        )

对图重新布局:将每个顶点移动到其在布局中的位置。

顶点一次性移动,边在下一帧跟随,由图的更新器移动。若要为变化设置动画, 请将每个顶点动画移动到已更改副本中的位置(如下所示):边会全程跟随。

布局函数收到一个由当前顶点和边构成的全新 NetworkX 图。 其节点、边和图属性属于该次调用,而非后续布局。

generic_graph.change_layout(layout='spring', layout_scale=2, layout_config=None, partitions=None, root_vertex=None)
layout

顶点所在之处:布局的名称、其位置,或一个 布局函数(参见 GenericGraph)。

layout_scale

布局从中心向外延伸的距离,以场景单位计。

layout_config

布局函数的关键字;None 表示无。

partitions

用于 "partite" 布局:每列的顶点;None 表示无。

root_vertex

用于 "tree" 布局:位于顶部的顶点;None 表示无。

源码

manimgx\mobjects\graph.py

def change_layout(
    self,
    layout: Layout[V] = "spring",
    layout_scale: float | tuple[float, float, float] = 2,
    layout_config: Mapping[str, object] | None = None,
    partitions: Sequence[Sequence[V]] | None = None,
    root_vertex: V | None = None,
) -> Self:
    """对图重新布局:将每个顶点移动到其在布局中的位置。

    顶点一次性移动,边在下一帧跟随,由图的更新器移动。若要为变化设置动画,
    请将每个顶点动画移动到已更改副本中的位置(如下所示):边会全程跟随。

    布局函数收到一个由当前顶点和边构成的全新 NetworkX 图。
    其节点、边和图属性属于该次调用,而非后续布局。

    Args:
        layout: 顶点所在之处:布局的名称、其位置,或一个
            布局函数(参见
            [GenericGraph][manimgx.mobjects.graph.GenericGraph])。
        layout_scale: 布局从中心向外延伸的距离,以场景单位计。
        layout_config: 布局函数的关键字;None 表示无。
        partitions: 用于 `"partite"` 布局:每列的顶点;None
            表示无。
        root_vertex: 用于 `"tree"` 布局:位于顶部的顶点;None 表示无。

    Examples:
        ```python
        import manimgx as m


        class GraphChangeLayoutExample(m.Scene):
            def construct(self) -> None:
                graph = m.Graph(
                    [1, 2, 3, 4, 5, 6],
                    [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 1), (1, 4)],
                    layout={v: [2 * v - 7, 0, 0] for v in range(1, 7)},
                )
                circle = graph.copy().change_layout("circular", layout_scale=3)
                self.add(graph)
                self.play(
                    *(graph[v].animate.move_to(circle[v]) for v in graph.vertices)
                )
        ```
    """
    return self._place_vertices(
        self.edges,
        layout=layout,
        layout_scale=layout_scale,
        layout_config=layout_config,
        partitions=partitions,
        root_vertex=root_vertex,
    )

from_networkx

代码
import networkx as nx

import manimgx as m


class GraphFromNetworkxExample(m.Scene):
    def construct(self) -> None:
        petersen = nx.petersen_graph()
        graph = m.Graph.from_networkx(
            petersen,
            layout="shell",
            layout_scale=3,
            layout_config={"nlist": [range(5, 10), range(5)]},
        )
        self.play(m.Create(graph), run_time=2)

由 NetworkX 图的节点和边构造一个图。

GenericGraph.from_networkx(nxgraph, **kwargs)
nxgraph

NetworkX 图(一个 Graph,或一个 DiGraph)。

labels

每个顶点是否以其名称标注,名称以数学排版,或为每个顶点指定 标签(默认 False)。

label_fill_color

由名称生成的标签的颜色(默认黑色)。

layout

顶点所在之处:布局的名称、其位置或一个布局函数 (默认 "spring")。

layout_scale

布局从中心向外延伸的距离,以场景单位计(默认 2)。

layout_config

布局函数的关键字:"spring" 布局的 seed,……(默认 None: 无)。

vertex_type

顶点的类(默认 Dot;带标签的为 LabeledDot)。

vertex_config

顶点的关键字:对所有顶点生效,以及某个顶点在其名称下的独有配置,取代 对所有顶点的配置(默认 None:无)。

vertex_mobjects

作为顶点本身的 Mobject,按顶点指定(默认 None:无)。

edge_type

边的类(默认 Line)。

partitions

用于 "partite" 布局:每列的顶点,按顺序排列(默认 None: 无)。

root_vertex

用于 "tree" 布局:位于顶部的顶点(默认 None:无)。

edge_config

边的关键字:对所有边生效,以及某条边在其顶点对下的独有配置,取代 对所有边的配置(默认 None:无)。

返回 一个新的图。

源码

manimgx\mobjects\graph.py

@classmethod
def from_networkx(cls, nxgraph: NxGraph, **kwargs: Unpack[GraphOptions[V]]) -> Self:
    """由 [NetworkX](https://networkx.org) 图的节点和边构造一个图。

    Args:
        nxgraph: NetworkX 图(一个 `Graph`,或一个 `DiGraph`)。
        **kwargs: [图关键字][manimgx.Graph]:`layout`、
            `labels`、`vertex_config`,……。

    Returns:
        一个新的图。

    Examples:
        ```python
        import networkx as nx

        import manimgx as m


        class GraphFromNetworkxExample(m.Scene):
            def construct(self) -> None:
                petersen = nx.petersen_graph()
                graph = m.Graph.from_networkx(
                    petersen,
                    layout="shell",
                    layout_scale=3,
                    layout_config={"nlist": [range(5, 10), range(5)]},
                )
                self.play(m.Create(graph), run_time=2)
        ```
    """
    return cls(list(nxgraph.nodes), list(nxgraph.edges), **kwargs)

update_edges

将每条边重新放回其顶点上,按顶点当前位置:图每帧运行的更新器, 使其边跟随其顶点。

每种图以各自的方式设置边的两端:无向图从中心到中心,有向图从轮廓到轮廓, 并带有尖端。只有作为线条的边(Line 及其子类)会跟随。

generic_graph.update_edges(graph)
graph

更新器为之运行的 mobject(该图);未使用。

源码

manimgx\mobjects\graph.py

def update_edges(self, graph: Mobject) -> Self:
    """将每条边重新放回其顶点上,按顶点当前位置:图每帧运行的更新器,
    使其边跟随其顶点。

    每种图以各自的方式设置边的两端:无向图从中心到中心,有向图从轮廓到轮廓,
    并带有尖端。只有作为线条的边([Line][manimgx.Line] 及其子类)会跟随。

    Args:
        graph: 更新器为之运行的 mobject(该图);未使用。
    """
    raise NotImplementedError("To be implemented in concrete subclasses")

VertexOptions

add_vertices 的关键字, 用于传递它们的方法:新顶点所在之处、其标签、其类型及其关键字。

positions

新顶点所在之处,按顶点指定(默认 None:位于图的中心)。

labels

每个新顶点是否以其名称标注,名称以数学排版:True 表示 全部标注,或按顶点指定,True 或自定义标签(默认 False)。

label_fill_color

由名称生成的标签的颜色(默认黑色)。

vertex_type

新顶点的类(默认 Dot;带标签的为 LabeledDot)。

vertex_config

新顶点的关键字,覆盖图自身的:对所有顶点生效,以及某个顶点 在其名称下的独有配置,取代对所有顶点的配置(默认 None:无)。

vertex_mobjects

作为顶点本身的 Mobject,按顶点指定(默认 None:无)。

positions

新顶点所在之处,按顶点指定(默认 None:位于图的中心)。

labels

每个新顶点是否以其名称标注,名称以数学排版:True 表示 全部标注,或按顶点指定,True 或自定义标签(默认 False)。

label_fill_color

由名称生成的标签的颜色(默认黑色)。

vertex_type

新顶点的类(默认 Dot;带标签的为 LabeledDot)。

vertex_config

新顶点的关键字,覆盖图自身的:对所有顶点生效,以及某个顶点 在其名称下的独有配置,取代对所有顶点的配置(默认 None:无)。

vertex_mobjects

作为顶点本身的 Mobject,按顶点指定(默认 None:无)。