MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / from_graph

Method from_graph

easygraph/classes/hypergraph.py:209–221  ·  view source on GitHub ↗

r"""Construct the hypergraph from the graph. Each edge in the graph is treated as a hyperedge in the constructed hypergraph. .. note:: The construsted hypergraph is a 2-uniform hypergraph, and has the same number of vertices and edges/hyperedges as the graph. Args:

(graph, device: torch.device = torch.device("cpu"))

Source from the content-addressed store, hash-verified

207
208 @staticmethod
209 def from_graph(graph, device: torch.device = torch.device("cpu")) -> "Hypergraph":
210 r"""Construct the hypergraph from the graph. Each edge in the graph is treated as a hyperedge in the constructed hypergraph.
211
212 .. note::
213 The construsted hypergraph is a 2-uniform hypergraph, and has the same number of vertices and edges/hyperedges as the graph.
214
215 Args:
216 ``graph`` (``eg.Graph``): The graph to construct the hypergraph.
217 ``device`` (``torch.device``, optional): The device to store the hypergraph. Defaults to ``torch.device('cpu')``.
218 """
219 e_list, e_weight = graph.e
220 hg = Hypergraph(len(graph.nodes), e_list, e_weight=e_weight, device=device)
221 return hg
222
223 @staticmethod
224 def _e_list_from_graph_kHop(

Callers 2

test_from_graphFunction · 0.80

Calls 1

HypergraphClass · 0.85

Tested by 2

test_from_graphFunction · 0.64