r"""Construct the hypergraph from the graph by k-Hop neighbors. Each hyperedge in the hypergraph is constructed by the central vertex and its :math:`k`-Hop neighbor vertices. .. note:: If the graph have :math:`|\mathcal{V}|` vertices, the constructed hypergraph will have :math:`
(
graph,
k: int,
only_kHop: bool = False,
device: torch.device = torch.device("cpu"),
)
| 257 | |
| 258 | @staticmethod |
| 259 | def from_graph_kHop( |
| 260 | graph, |
| 261 | k: int, |
| 262 | only_kHop: bool = False, |
| 263 | device: torch.device = torch.device("cpu"), |
| 264 | ) -> "Hypergraph": |
| 265 | r"""Construct the hypergraph from the graph by k-Hop neighbors. Each hyperedge in the hypergraph is constructed by the central vertex and its :math:`k`-Hop neighbor vertices. |
| 266 | |
| 267 | .. note:: |
| 268 | If the graph have :math:`|\mathcal{V}|` vertices, the constructed hypergraph will have :math:`|\mathcal{V}|` vertices and equal to or less than :math:`|\mathcal{V}|` hyperedges. |
| 269 | |
| 270 | Args: |
| 271 | ``graph`` (``eg.Graph``): The graph to construct the hypergraph. |
| 272 | ``k`` (``int``): The number of hop neighbors. |
| 273 | ``only_kHop`` (``bool``): If set to ``True``, only the central vertex and its :math:`k`-th Hop neighbors are used to construct the hyperedges. By default, the constructed hyperedge will include the central vertex and its [ :math:`1`-th, :math:`2`-th, :math:`\cdots`, :math:`k`-th ] Hop neighbors. Defaults to ``False``. |
| 274 | ``device`` (``torch.device``, optional): The device to store the hypergraph. Defaults to ``torch.device('cpu')``. |
| 275 | """ |
| 276 | e_list = Hypergraph._e_list_from_graph_kHop(graph, k, only_kHop) |
| 277 | hg = Hypergraph(len(graph.nodes), e_list, device=device) |
| 278 | return hg |
| 279 | |
| 280 | def add_hyperedges( |
| 281 | self, |