xgi.core.views.EdgeView#
- class 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
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
Get the node ids that are members of an edge.
Edges that contain exactly one node.
Returns the maximal edges as an EdgeView.
Find the neighbors of an ID.
Find IDs that have a duplicate.
Find IDs with the specified bipartite neighbors.
Filter the IDs in this view by a statistic.
Filter the IDs in this view by an attribute.
- empty()[source]#
Edges that contain no nodes.
- Return type:
EdgeView containing the empty edges.
See also
- 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:
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