Skip to content

Commit

Permalink
Update (dmlc#2354)
Browse files Browse the repository at this point in the history
  • Loading branch information
mufeili authored Nov 18, 2020
1 parent 061c2a3 commit 9c08cd6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/source/guide/graph-feature.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
The nodes and edges of a :class:`~dgl.DGLGraph` can have several user-defined named features for
storing graph-specific properties of the nodes and edges. These features can be accessed
via the :py:attr:`~dgl.DGLGraph.ndata` and :py:attr:`~dgl.DGLGraph.edata` interface. For example, the following code creates two node
features (named ``'x'`` and ``'y'`` in line 5 and 8) and one edge feature (named ``'x'`` in line 6).
features (named ``'x'`` and ``'y'`` in line 8 and 15) and one edge feature (named ``'x'`` in line 9).

.. code-block:: python
:linenos:
Expand Down Expand Up @@ -45,7 +45,7 @@ Important facts about the :py:attr:`~dgl.DGLGraph.ndata`/:py:attr:`~dgl.DGLGraph
nodes/edges in the graph.
- Features of the same name must have the same dimensionality and data type.
- The feature tensor is in row-major layout -- each row-slice stores the feature of one
node or edge (e.g., see lines 10-11 in the above example).
node or edge (e.g., see lines 16 and 18 in the above example).

For weighted graphs, one can store the weights as an edge feature as below.

Expand Down
4 changes: 2 additions & 2 deletions docs/source/guide_cn/graph-feature.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

:class:`~dgl.DGLGraph` 对象的节点和边可具有多个用户定义的、可命名的特征,以储存图的节点和边的属性。
通过 :py:attr:`~dgl.DGLGraph.ndata` 和 :py:attr:`~dgl.DGLGraph.edata` 接口可访问这些特征。
例如,以下代码创建了2个节点特征(分别在第5、8行命名为 ``'x'`` 、 ``'y'`` )和1个边特征(在第6行命名为 ``'x'`` )。
例如,以下代码创建了2个节点特征(分别在第8、15行命名为 ``'x'`` 、 ``'y'`` )和1个边特征(在第9行命名为 ``'x'`` )。

.. code-block:: python
:linenos:
Expand Down Expand Up @@ -39,7 +39,7 @@
- 通过张量分配创建特征时,DGL会将特征赋给图中的每个节点和每条边。该张量的第一维必须与图中节点或边的数量一致。
不能将特征赋给图中节点或边的子集。
- 相同名称的特征必须具有相同的维度和数据类型。
- 特征张量使用"行优先"的原则,即每个行切片储存1个节点或1条边的特征(参考上述示例代码的第10~11行)。
- 特征张量使用"行优先"的原则,即每个行切片储存1个节点或1条边的特征(参考上述示例代码的第16和18行)。

对于加权图,用户可以将权重储存为一个边特征,如下。

Expand Down

0 comments on commit 9c08cd6

Please sign in to comment.