xgi.core.views.EdgeView

class xgi.core.views.EdgeView(H, bunch=None)[source]

Bases: IDView

An IDView that keeps track of edge ids.

Parameters:
  • hypergraph (Hypergraph) – The hypergraph whose edges this view will keep track of.

  • bunch (optional iterable, default None) – The edge ids to keep track of. If None (default), keep track of all edge ids.

See also

IDView

Notes

In addition to the methods listed in this page, other methods defined in the stats package are also accessible via the EdgeView class. For more details, see the tutorial.

Attributes

ids

The ids in this view.

Methods

members

Get the node ids that are members of an edge.

singletons

Edges that contain exactly one node.

maximal

Returns the maximal edges as an EdgeView.

neighbors

Find the neighbors of an ID.

duplicates

Find IDs that have a duplicate.

lookup

Find IDs with the specified bipartite neighbors.

filterby

Filter the IDs in this view by a statistic.

filterby_attr

Filter the IDs in this view by an attribute.

maximal(strict=False)[source]

Returns the maximal edges as an EdgeView.

Maximal edges are those that are not subsets of any other edges in the hypergraph. The strict keyword determines whether the subsets are strict or non-strict.

Parameters:

strict (bool, optional) – Whether maximal edges must strictly include all of its subsets (strict=True) or whether maximal multiedges are permitted (strict=False), by default False. See Notes for more details.

Returns:

The maximal edges

Return type:

EdgeView

Notes

This function implements two definitions of maximal hyperedges: strict and non-strict. For the strict case (strict=True), we enforce that a maximal edge must strictly include all of its subsets and by this definition, multiedges can’t be included. For the non-strict case (strict=False), then we add all the maximal multiedges with non-strict inclusion.

There are methods for eliminating these duplicates by running H.cleanup() or H.remove_edges_from(H.edges.duplicates())

References

https://stackoverflow.com/questions/14106121/efficient-algorithm-for-finding-all-maximal-subsets

Example

>>> import xgi
>>> H = xgi.Hypergraph([{1, 2, 3},{1, 2}, {2, 3}, {2}, {2}, {3, 4}, {1, 2, 3}])
>>> H.edges.maximal()
EdgeView((0, 5, 6))
>>> H.edges.maximal().members()
[{1, 2, 3}, {3, 4}, {1, 2, 3}]
members(e=None, dtype=<class 'list'>)[source]

Get the node ids that are members of an edge.

Parameters:
  • e (hashable, optional) – Edge ID. By default, None.

  • dtype ({list, dict}, optional) – Specify the type of the return value. By default, list.

Returns:

  • list (if dtype is list, default) – Edge members.

  • dict (if dtype is dict) – Edge members.

  • set (if e is not None) – Members of edge e.

Raises:
  • TypeError – If e is not None or a hashable

  • XGIError – If dtype is not dict or list

  • IDNotFound – If e does not exist in the hypergraph

singletons()[source]

Edges that contain exactly one node.

Return type:

EdgeView containing the singleton edges.