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

Method drop_hyperedges

easygraph/classes/hypergraph.py:407–430  ·  view source on GitHub ↗

r"""Randomly drop hyperedges from the hypergraph. This function will return a new hypergraph with non-dropped hyperedges. Args: ``drop_rate`` (``float``): The drop rate of hyperedges. ``ord`` (``str``): The order of dropping edges. Currently, only ``'uniform'`` is su

(self, drop_rate: float, ord="uniform")

Source from the content-addressed store, hash-verified

405 self._clear_cache(group_name)
406
407 def drop_hyperedges(self, drop_rate: float, ord="uniform"):
408 r"""Randomly drop hyperedges from the hypergraph. This function will return a new hypergraph with non-dropped hyperedges.
409
410 Args:
411 ``drop_rate`` (``float``): The drop rate of hyperedges.
412 ``ord`` (``str``): The order of dropping edges. Currently, only ``'uniform'`` is supported. Defaults to ``uniform``.
413 """
414 if ord == "uniform":
415 _raw_groups = {}
416 for name in self.group_names:
417 _raw_groups[name] = {
418 k: v
419 for k, v in self._raw_groups[name].items()
420 if random.random() > drop_rate
421 }
422 state_dict = {
423 "num_v": self.num_v,
424 "raw_groups": _raw_groups,
425 }
426 _hg = Hypergraph.from_state_dict(state_dict)
427 _hg = _hg.to(self.device)
428 else:
429 raise ValueError(f"Unknown drop order: {ord}.")
430 return _hg
431
432 def drop_hyperedges_of_group(
433 self, group_name: str, drop_rate: float, ord="uniform"

Callers

nothing calls this directly

Calls 2

from_state_dictMethod · 0.45
toMethod · 0.45

Tested by

no test coverage detected