Skip to content

Commit 126f844

Browse files
committed
Update vis_structure.rst
1 parent 8e1342c commit 126f844

File tree

1 file changed

+51
-25
lines changed

1 file changed

+51
-25
lines changed

docs/source/zh/tutorial/vis_structure.rst

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
- 翻译:颜杰龙
88
- 校对: `丰一帆 <https://fengyifan.site/>`_
99

10-
Basic Usages
10+
基本用法
1111
--------------
12-
DHG provides a simple interface to visualize the correlation structures:
12+
DHG提供了一种简单的接口来可视化关联结构:
1313

14-
1. Create a structure object (*i.e.*, :py:class:`dhg.Graph`, :py:class:`dhg.BiGraph`, :py:class:`dhg.DiGraph`, and :py:class:`dhg.Hypergraph`);
15-
2. Call the ``draw()`` method of the object;
16-
3. Call ``plt.show()`` to show the figure or ``plt.savefig()`` to save the figure.
14+
1. 构造关联结构对象 (*也就是*, :py:class:`dhg.Graph` :py:class:`dhg.BiGraph` :py:class:`dhg.DiGraph` :py:class:`dhg.Hypergraph`);
15+
2. 调用对象的 ``draw()`` 方法;
16+
3. 调用 ``plt.show()`` 显示图片或者 ``plt.savefig()`` 保存图片。
1717

18-
.. note:: The ``plt`` is short for ``matplotlib.pyplot`` module.
18+
.. note:: ``plt`` ``matplotlib.pyplot`` 模块的缩写。
1919

2020

21-
Visualization of Graph
21+
图的可视化
2222
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2323

2424
.. image:: ../../_static/img/vis_graph.png
@@ -36,7 +36,7 @@ Visualization of Graph
3636
>>> plt.show()
3737
3838
39-
Visualization of Directed Graph
39+
有向图的可视化
4040
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4141

4242
.. image:: ../../_static/img/vis_digraph.png
@@ -53,7 +53,7 @@ Visualization of Directed Graph
5353
>>> plt.show()
5454
5555
56-
Visualization of Bipartite Graph
56+
二分图的可视化
5757
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5858

5959

@@ -71,7 +71,7 @@ Visualization of Bipartite Graph
7171
>>> plt.show()
7272
7373
74-
Visualization of Hypergraph
74+
超图的可视化
7575
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7676

7777
.. image:: ../../_static/img/vis_hypergraph.png
@@ -89,16 +89,19 @@ Visualization of Hypergraph
8989
9090
9191
92-
Advanced Usages
92+
高级用法
9393
---------------------
9494

95-
Customize Labels
95+
自定义标签
9696
^^^^^^^^^^^^^^^^^^^^^^^^^
97-
The labels of the vertices could be customized by the ``v_label`` argument. The ``v_label`` could be a list of strings. The labels of the vertices are the strings in the list.
98-
For example, the following code shows how to customize the labels of the vertices of a graph.
99-
If the ``v_label`` is not specified, no labels will be shown in the figure.
100-
The ``font_size`` argument for ``dhg.Graph``, ``dhg.DiGraph``, and ``dhg.Hypergraph``, as well as ``u_font_size`` and ``v_font_size`` for ``dhg.BiGraph`` is used to specify the relative size of the font of the labels, and the default value is ``1.0``.
101-
The ``font_family`` argument is used to specify the font family of the labels, and the default value is ``'sans-serif'``.
97+
顶点的标签可以通过 ``v_label`` 参数自定义。
98+
``v_label`` 可以为字符串列表。
99+
顶点的标签为列表中的字符串。
100+
例如,以下代码显示如何自定义图关联结构中顶点的标签。
101+
如果没有指定 ``v_label`` , 那么图中不会显示任何标签。
102+
``dhg.Graph``、 ``dhg.DiGraph`` 和 ``dhg.Hypergraph`` 中的 ``font_size`` 参数以及 ``dhg.BiGraph`` 中的 ``u_font_size`` 和 ``v_font_size`` 参数用于指定标签字体的相对大小,
103+
其默认值为 ``1.0`` 。
104+
``font_family`` 参数用于指定标签的字体,其默认值为 ``'sans-serif'`` 。
102105

103106
.. code-block:: python
104107
@@ -115,9 +118,16 @@ The ``font_family`` argument is used to specify the font family of the labels, a
115118
:height: 400px
116119

117120

118-
Customize Colors
121+
自定义颜色
119122
^^^^^^^^^^^^^^^^^^^^^^^^^
120-
For ``dhg.Graph``, ``dhg.DiGraph``, and ``dhg.Hypergraph``, the colors of the vertices could be customized by the ``v_color`` argument and the colors of the edges could be customized by the ``e_color`` argument. While for ``dhg.BiGraph``, the colors of the vertices in :math:`\mathcal{U}` could be customized by the ``u_color`` argument and the colors of the vertices in :math:`\mathcal{V}` could be customized by the ``v_color`` argument. Both the ``v_color``, ``u_color``, and ``e_color`` could be a string or list of strings. If a string is provided, all the vertices or edges will be colored by the string. If a list of strings is provided, the colors of the vertices or edges are the strings in the list. For example, the following code shows how to customize the colors of the vertices and edges of a hypergraph.
123+
对于 ``dhg.Graph`` 、 ``dhg.DiGraph`` 和 ``dhg.Hypergraph`` ,
124+
顶点的颜色可以由 ``v_color`` 参数指定,边的颜色可以由 ``e_color`` 指定。
125+
对于 ``dhg.BiGraph`` , 集合 :math:`\mathcal{U}` 内顶点的颜色可以由 ``u_color`` 参数指定,
126+
集合 :math:`\mathcal{V}` 内顶点的颜色可以由 ``v_color`` 参数指定。
127+
``v_color`` 、 ``u_color`` 和 ``e_color`` 参数为单个字符串或者字符串列表。
128+
若为单个字符串,那么所有的顶点或边将根据该字符串着色。
129+
若为字符串列表,顶点或者边的颜色为该列表中的字符串。
130+
例如,以下代码显示如何自定义超图的顶点和边的颜色。
121131

122132
.. code-block:: python
123133
@@ -133,10 +143,19 @@ For ``dhg.Graph``, ``dhg.DiGraph``, and ``dhg.Hypergraph``, the colors of the ve
133143
:height: 400px
134144

135145

136-
Customize Sizes
146+
自定义大小
137147
^^^^^^^^^^^^^^^^^^^^^^^^^
138-
For ``dhg.Graph``, ``dhg.DiGraph``, and ``dhg.Hypergraph``, the sizes of the vertices could be customized by the ``v_size`` argument and the sizes of the edges could be customized by the ``e_size`` argument. While for ``dhg.BiGraph``, the sizes of the vertices in :math:`\mathcal{U}` could be customized by the ``u_size`` argument and the sizes of the vertices in :math:`\mathcal{V}` could be customized by the ``v_size`` argument. Both the ``v_size``, ``u_size``, and ``e_size`` could be a float or list of float. If a float is provided, all the vertices or edges will be sized by the float. If a list of floats is provided, the sizes of the vertices or edges are the floats in the list. ``v_line_width`` represents the width of the surrounding line of the vertices. ``e_line_width`` represents the width of the line of the edges.
139-
All of the sizes above represent the relative size, and the default values are ``1.0``. For example, the following code shows how to customize the sizes of the vertices and edges of a hypergraph.
148+
对于 ``dhg.Graph`` 、 ``dhg.DiGraph`` 和 ``dhg.Hypergraph`` ,
149+
顶点的大小可以由 ``v_size`` 参数指定,边的大小可以由 ``e_size`` 参数指定。
150+
对于 ``dhg.BiGraph`` , 集合 :math:`\mathcal{U}` 内顶点的大小可以由 ``u_size`` 参数指定,
151+
集合 :math:`\mathcal{V}` 内顶点的大小可以由 ``v_size`` 参数指定。
152+
``v_size`` 、 ``u_size`` 和 ``e_size`` 参数为单个浮点数或者浮点数列表。
153+
若为单个浮点数,那么所有的顶点或边将根据该浮点数调整大小。
154+
若为浮点数列表,顶点或者边的大小为该列表中的浮点数。
155+
``v_line_width`` 表示顶点周围线的宽度。
156+
``e_line_width`` 表示边周围线的宽度。
157+
以上所有的大小为相对大小,默认值为 ``1.0`` 。
158+
例如,以下代码显示如何自定义超图的顶点和边的大小。
140159

141160
.. code-block:: python
142161
@@ -153,10 +172,17 @@ All of the sizes above represent the relative size, and the default values are `
153172

154173

155174

156-
Customize Layout
175+
自定义布局
157176
^^^^^^^^^^^^^^^^^^^^^^^^^
158-
The layout of the structures is based on the modified directed-force layout algorithm. There are four forces to determine the position of the nodes, *i.e.*, node attraction force :math:`f_{na}`, node repulsion force :math:`f_{nr}`, edge repulsion force :math:`f_{er}`, and the center force :math:`f_c`. :math:`f_{na}` is the spring force which attracts the adjacent nodes. :math:`f_{nr}` is used to repel the nodes from each other. :math:`f_{er}` is used to repel the hyperedges from each other, which only make sense for hypergraph visualization. :math:`f_c` is used to attract the nodes to the center (two centers for the bipartite graphs).
159-
The strength of the forces could be customized by ``forces`` argument, which is a dictionary with the keys ``Simulator.NODE_ATTRACTION``, ``Simulator.NODE_REPULSION``, ``Simulator.EDGE_REPULSION``, and ``Simulator.CENTER_GRAVITY``. The default values of the forces are ``1.0``.
177+
关联结构的布局基于改进后的定向力布局算法。
178+
顶点的位置由四种力确定,也就是,顶点吸引力 :math:`f_{na}` 、顶点斥力 :math:`f_{nr}`、 边斥力 :math:`f_{er}` 和 中心力 :math:`f_c`。
179+
:math:`f_{na}` 是吸引相邻顶点的弹力。
180+
:math:`f_{nr}` 用于将顶点相互排斥。
181+
:math:`f_{er}` 用于将超边相互排斥,其只用于超图可视化。
182+
:math:`f_c` 用于将顶点吸引到中心(二分图的两个中心)。
183+
各种力的强度可以通过 ``forces`` 参数自定义,该参数是包含
184+
``Simulator.NODE_ATTRACTION`` 、 ``Simulator.NODE_REPULSION`` 、 ``Simulator.EDGE_REPULSION`` 和 ``Simulator.CENTER_GRAVITY`` 键值的字典。
185+
力的默认值为 ``1.0`` 。
160186

161187

162188
.. different style, change size, change color, change opacity

0 commit comments

Comments
 (0)