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

Method remove_hyperedges

easygraph/classes/base.py:387–418  ·  view source on GitHub ↗

r"""Remove the specified hyperedges from the hypergraph. Args: ``e_list_v2e`` (``Union[List[int], List[List[int]]]``): A list of hyperedges describes how the vertices point to the hyperedges. ``e_list_e2v`` (``Union[List[int], List[List[int]]]``): A list of hyperedge

(
        self,
        e_list_v2e: Union[List[int], List[List[int]]],
        e_list_e2v: Union[List[int], List[List[int]]],
        group_name: Optional[str] = None,
    )

Source from the content-addressed store, hash-verified

385 )
386
387 def remove_hyperedges(
388 self,
389 e_list_v2e: Union[List[int], List[List[int]]],
390 e_list_e2v: Union[List[int], List[List[int]]],
391 group_name: Optional[str] = None,
392 ):
393 r"""Remove the specified hyperedges from the hypergraph.
394
395 Args:
396 ``e_list_v2e`` (``Union[List[int], List[List[int]]]``): A list of hyperedges describes how the vertices point to the hyperedges.
397 ``e_list_e2v`` (``Union[List[int], List[List[int]]]``): A list of hyperedges describes how the hyperedges point to the vertices.
398 ``group_name`` (``str``, optional): Remove these hyperedges from the specified hyperedge group. If not specified, the function will
399 remove those hyperedges from all hyperedge groups. Defaults to the ``None``.
400 """
401 assert (
402 group_name in self.group_names
403 ), f"The specified {group_name} is not in existing hyperedge groups."
404 assert len(e_list_v2e) == len(
405 e_list_e2v
406 ), "Hyperedges of 'v2e' and 'e2v' must have the same size."
407 e_list_v2e = self._format_e_list(e_list_v2e)
408 e_list_e2v = self._format_e_list(e_list_e2v)
409 if group_name is None:
410 for _idx in range(len(e_list_v2e)):
411 e_code = self._hyperedge_code(e_list_v2e[_idx], e_list_e2v[_idx])
412 for name in self.group_names:
413 self._raw_groups[name].pop(e_code, None)
414 else:
415 for _idx in range(len(e_list_v2e)):
416 e_code = self._hyperedge_code(e_list_v2e[_idx], e_list_e2v[_idx])
417 self._raw_groups[group_name].pop(e_code, None)
418 self._clear_cache(group_name)
419
420 @abc.abstractmethod
421 def drop_hyperedges(self, drop_rate: float, ord="uniform"):

Callers 2

test_remove_hyperedgesFunction · 0.45

Calls 4

_format_e_listMethod · 0.95
_hyperedge_codeMethod · 0.95
_clear_cacheMethod · 0.95
popMethod · 0.80

Tested by 2

test_remove_hyperedgesFunction · 0.36