Skip to content

Commit 6eeccd6

Browse files
committed
update doc structure
1 parent 6bb3e59 commit 6eeccd6

13 files changed

Lines changed: 172 additions & 28 deletions

File tree

‎docs/source/start/high_order/hypergraph.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Learning on Simple Hypergraph
55

66
Definition
77
-----------------
8-
`Simple hypergraph <https://en.wikipedia.org/wiki/Hypergraph>`_ (also called undirected hypergraph) can be indicated with :math:`\mathcal{G} = \{\mathcal{V}, \mathcal{E}\}`.
8+
A `simple hypergraph <https://en.wikipedia.org/wiki/Hypergraph>`_ (also called undirected hypergraph) can be indicated with :math:`\mathcal{G} = \{\mathcal{V}, \mathcal{E}\}`.
99

1010
- :math:`\mathcal{V}`, is a set of **vertices** (also called **nodes** or **points**);
1111
- :math:`\mathcal{E} \subseteq \{ \mathcal{P}(\mathcal{V}) \}`, a set of **hyperedges** (also called **edges**), where :math:`\mathcal{P}(\mathcal{V})` is the `power set <https://en.wikipedia.org/wiki/Power_set>`_ of :math:`\mathcal{V}`.
@@ -22,7 +22,7 @@ An undirected hypergraph is also called a set system or a family of sets drawn f
2222

2323
Construction
2424
---------------------
25-
The simple hypergraph structure can be constructed by the following methods. More details can refer to aaaaaaaaaaaaa.
25+
The simple hypergraph structure can be constructed by the following methods. More details can refer to :ref:`here <build_hypergraph>`.
2626

2727
- Hyperedge list (**default**) :py:class:`dhg.Hypergraph`
2828
- Features with k-Nearest Neighbors :py:meth:`dhg.Hypergraph.from_feature_kNN`

‎docs/source/start/low_order/bipartite_graph.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ different scenarios like: movie/news/goods/hotels/products/services recommender.
2222

2323
Construction
2424
-------------------------
25-
The bipartite graph structure can be constructed by the following methods. More details can refer to aaaaaaaaaaaaa.
25+
The bipartite graph structure can be constructed by the following methods. More details can refer to :ref:`here <build_bipartite_graph>`.
2626

2727
- Edge list (**default**) :py:class:`dhg.BiGraph`
2828
- Adjacency list :py:meth:`dhg.BiGraph.from_adj_list`

‎docs/source/start/low_order/directed_graph.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ A vertex may exist in a directed graph and not belong to an edge. The edge :math
2121
Construction
2222
-------------------------
2323

24-
The directed graph structure can be constructed by the following methods. More details can refer to aaaaaaaaaaaaa.
24+
The directed graph structure can be constructed by the following methods. More details can refer to :ref:`here <build_directed_graph>`.
2525

2626
- Edge list (**default**) :py:class:`dhg.DiGraph`
2727
- Adjacency list :py:meth:`dhg.DiGraph.from_adj_list`

‎docs/source/start/low_order/graph.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ A vertex may exist in a simple graph and not belong to an edge.
1616

1717
Construction
1818
-------------------------
19-
The simple graph structure can be constructed by the following methods. More details can refer to aaaaaaaaaaaaa.
19+
The simple graph structure can be constructed by the following methods. More details can refer to :ref:`here <build_graph>`.
2020

2121
- Edge list (**default**) :py:class:`dhg.Graph`
2222
- Adjacency list :py:meth:`dhg.Graph.from_adj_list`

‎docs/source/start/structure.rst‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ Applications
3232
:header: Structure, "Applications", "Example Code"
3333
:widths: 2, 6, 3
3434

35-
"Simple Graph", "Paper Classification of Citation Networks, *etc.*", "aaaaaaaaaa"
36-
"Directed Graph", "Point Clouds Classification, *etc.*", "aaaaaaaaa"
35+
"Simple Graph", "Paper Classification of Citation Networks, *etc.*", ":doc:`example </examples/vertex_cls/graph>`"
36+
"Directed Graph", "Point Clouds Classification, *etc.*", "\-"
3737
"Bipartite Graph", "| Item Recommender of User-Item Graph,
38-
| Correlation Prediction of Potein-Drug Graph, *etc.*", "aaaaaaaaaaa"
38+
| Correlation Prediction of Potein-Drug Graph, *etc.*", ":doc:`example </examples/recommender>`"
3939
"Simple Hypergraph", "| Vertex Classification of Social Networks,
40-
| Visual Object Classification on Multi-Modal Visual Object Graph, *etc.*", "aaaaaaaaaa"
40+
| Visual Object Classification on Multi-Modal Visual Object Graph, *etc.*", ":doc:`example </examples/vertex_cls/hypergraph>`"
4141
4242

4343
Two Core Operations
@@ -309,8 +309,8 @@ Add Early Self-loop and Late Self-Loop
309309

310310
Self-loop is a important structure for feature learning especially for the simple graph structure.
311311
In the following examples, we introduce how to add early self-loop and late self-loop for spatial-based learning on the simple graph structure.
312+
We use :math:`\mathbf{A} \in \mathbb{R}^{N \times N}` to indicate the adjacency matrix of a given simple graph and :math:`\mathbf{X} \in \mathbb{R}^{N \times C}` to indicate the features of vertices in the given simple graph.
312313

313-
Add mathematical definition aaaaaaaaaaaaaaaaaaaaaaaaa
314314

315315
.. code:: python
316316
@@ -336,6 +336,16 @@ Add mathematical definition aaaaaaaaaaaaaaaaaaaaaaaaa
336336
Message Passing with Early Self-Loop
337337
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
338338

339+
.. math::
340+
341+
\left\{
342+
\begin{align}
343+
\mathbf{X}^\prime &= \hat{\mathbf{A}} \mathbf{X}\\
344+
\hat{\mathbf{A}} &= \mathbf{A} + \mathbf{I}
345+
\end{align}
346+
\right.
347+
348+
339349
.. code:: python
340350
341351
>>> # Print edges in the graph
@@ -364,6 +374,11 @@ Message Passing with Early Self-Loop
364374
Message Passing with Late Self-Loop
365375
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
366376

377+
.. math::
378+
379+
\mathbf{X}^\prime = \mathbf{A} \mathbf{X} + \mathbf{X}
380+
381+
367382
.. code:: python
368383
369384
>>> # Print edges in the graph

‎docs/source/tutorial/structure.rst‎

Lines changed: 119 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
Build Structure
22
===================================
33
Correlation structures are the core of **DHG**. In this section, we introduce the basic construction methods of different structures
4-
and some structure transformation functions of them like: *reducing the high-order structrue to the low-order structure*
5-
and *promoting the low-order structure to the high-order structure.*
4+
and some structure transformation functions of them like:
5+
6+
- Reducing the high-order structrue to the low-order structure
7+
- Promoting the low-order structure to the high-order structure
68

79
Low-Order Structures
810
-----------------------
911

12+
Currently, DHG's low-order structures include simple graph, directed graph, and bipartite graph.
13+
In the future, we will add more low-order structures.
14+
15+
.. _build_graph:
16+
1017
Build Simple Graph
1118
+++++++++++++++++++++++
1219

@@ -232,6 +239,7 @@ a method to reduce the hyperedges in the hypergraph to the edges in the simple g
232239
[0.3333, 0.3333, 0.3333, 0.0000, 0.3333],
233240
[0.0000, 0.0000, 0.0000, 0.3333, 0.0000]])
234241
242+
.. _build_directed_graph:
235243

236244
Build Directed Graph
237245
+++++++++++++++++++++++
@@ -316,6 +324,7 @@ Reduced from High-Order Structures
316324

317325
Welcome to contribute!
318326

327+
.. _build_bipartite_graph:
319328

320329
Build Bipartite Graph
321330
+++++++++++++++++++++++
@@ -433,17 +442,122 @@ We first define a simple hypergraph as:
433442
[0., 1., 1., 0., 0.],
434443
[1., 0., 0., 1., 1.]])
435444
445+
436446
High-Order Structures
437447
-----------------------
438-
Comming soon
448+
449+
Currently, DHG's high-order structures include simple hypergraph.
450+
In the future, we will add more high-order structures like directed hypergraph.
451+
452+
.. _build_hypergraph:
439453

440454
Build Simple Hypergraph
441455
++++++++++++++++++++++++++
442-
Comming soon
456+
A `simple hypergraph <https://en.wikipedia.org/wiki/Hypergraph>`_ is a hypergraph with no direction information in each hyperedge.
457+
Each hyperedge in a hypergraph can connect more than two vertices, which can be indicated with a sub-set of total vertices.
458+
Simple hypergraph can be constructed by the following methods:
459+
460+
- Hyperedge list (**default**) :py:class:`dhg.Hypergraph`
461+
- Features with k-Nearest Neighbors :py:meth:`dhg.Hypergraph.from_feature_kNN`
462+
- Promoted from the low-order structures
463+
464+
- Simple Graph :py:meth:`dhg.Hypergraph.from_graph`
465+
- k-Hop Neighbors of vertices in a simple graph :py:meth:`dhg.Hypergraph.from_graph_kHop`
466+
- Bipartite Graph :py:meth:`dhg.Hypergraph.from_bigraph`
467+
443468

444469
Common Methods
445470
^^^^^^^^^^^^^^^^^^^
446-
Comming soon
471+
472+
**Construct a simple hypergraph from edge list with** :py:class:`dhg.Hypergraph`
473+
474+
.. code-block:: python
475+
476+
>>> hg = dhg.Hypergraph(5, [(0, 1, 2), (2, 3), (0, 4)])
477+
>>> hg
478+
Simple Hypergraph(num_v=5, num_e=3)
479+
>>> hg.e
480+
([(0, 1, 2), (2, 3), (0, 4)], [1.0, 1.0, 1.0])
481+
>>> # print the incidence matrix of the simple hypergraph
482+
>>> hg.H.to_dense()
483+
tensor([[1., 0., 1.],
484+
[1., 0., 0.],
485+
[1., 1., 0.],
486+
[0., 1., 0.],
487+
[0., 0., 1.]])
488+
489+
.. important::
490+
491+
Each hyperedge in the hypergraph is an unordered set of vertices, which means that ``(0, 1, 2)``, ``(0, 2, 1)``, and ``(2, 1, 0)`` are all the same hyperedge.
492+
493+
.. code-block:: python
494+
495+
>>> hg = dhg.Hypergraph(5, [(0, 2, 1), (2, 3), (0, 4)])
496+
>>> hg.e
497+
([(0, 1, 2), (2, 3), (0, 4)], [1.0, 1.0, 1.0])
498+
>>> hg.H.to_dense()
499+
tensor([[1., 0., 1.],
500+
[1., 0., 0.],
501+
[1., 1., 0.],
502+
[0., 1., 0.],
503+
[0., 0., 1.]])
504+
>>> hg = dhg.Hypergraph(5, [(1, 0, 2), (2, 3), (0, 4)])
505+
>>> hg.e
506+
([(0, 1, 2), (2, 3), (0, 4)], [1.0, 1.0, 1.0])
507+
>>> hg.H.to_dense()
508+
tensor([[1., 0., 1.],
509+
[1., 0., 0.],
510+
[1., 1., 0.],
511+
[0., 1., 0.],
512+
[0., 0., 1.]])
513+
514+
.. note::
515+
516+
If the added hyperedges have duplicate hyperedges, those duplicate hyperedges will be automatically merged with specified ``merge_op``.
517+
518+
.. code-block:: python
519+
520+
>>> hg = dhg.Hypergraph(5, [(0, 1, 2), (2, 3), (2, 3), (0, 4)], merge_op="mean")
521+
>>> hg.e
522+
([(0, 1, 2), (2, 3), (0, 4)], [1.0, 1.0, 1.0])
523+
>>> hg = dhg.Hypergraph(5, [(0, 1, 2), (2, 3), (2, 3), (0, 4)], merge_op="sum")
524+
>>> hg.e
525+
([(0, 1, 2), (2, 3), (0, 4)], [1.0, 2.0, 1.0])
526+
>>> hg.add_hyperedges([(0, 2, 1), (0, 4)], merge_op="mean")
527+
>>> hg.e
528+
([(0, 1, 2), (2, 3), (0, 4)], [1.0, 2.0, 1.0])
529+
>>> hg.add_hyperedges([(0, 2, 1), (0, 4)], merge_op="sum")
530+
>>> hg.e
531+
([(0, 1, 2), (2, 3), (0, 4)], [2.0, 2.0, 2.0])
532+
533+
You can find the weight of the last hyperedge is ``1.0`` and ``2.0``, if you set the ``merge_op`` to ``mean`` and ``sum``, respectively.
534+
535+
536+
**Construct a simple hypergraph from feature k-Nearest Neighbors with** :py:meth:`dhg.Hypergraph.from_feature_kNN`
537+
538+
.. code-block:: python
539+
540+
>>> X = torch.tensor(([[0.6460, 0.0247],
541+
[0.9853, 0.2172],
542+
[0.7791, 0.4780],
543+
[0.0092, 0.4685],
544+
[0.9049, 0.6371]]))
545+
>>> hg = dhg.Hypergraph.from_feature_kNN(X, k=2)
546+
>>> hg
547+
Simple Hypergraph(num_v=5, num_e=3)
548+
>>> hg.e
549+
([(0, 1, 2), (1, 2, 4), (0, 2, 3)], [1.0, 1.0, 1.0])
550+
>>> hg.H.to_dense()
551+
tensor([[1., 0., 1.],
552+
[1., 1., 0.],
553+
[1., 1., 1.],
554+
[0., 0., 1.],
555+
[0., 1., 0.]])
556+
557+
.. note::
558+
559+
Those duplicated hyperedges are merged with ``mean`` operation.
560+
447561

448562
Prometed from Low-Order Structures
449563
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

‎docs/source/zh/start/high_order/hypergraph.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.. _zh_start_learning_on_simple_hypergraph:
22

3-
基于简单超图的学习
3+
简单超图上的表示学习
44
=================================
55

66
定义

‎docs/source/zh/start/high_order/index.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
根据高阶关联结构学习
1+
高阶关联结构上的表示学习
22
=====================================
33

44

‎docs/source/zh/start/low_order/bipartite_graph.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
.. _zh_start_learning_on_bipartite_graph:
33

4-
基于二分图的学习
4+
二分图上的表示学习
55
==============================
66

77
定义

‎docs/source/zh/start/low_order/directed_graph.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
基于有向图的学习
2+
有向图上的表示学习
33
=============================
44

55
定义

0 commit comments

Comments
 (0)