HypergraphDB Class¶
hyperdb.hypergraph.HypergraphDB
dataclass
¶
HypergraphDB(
storage_file: Union[str, Path] = "my_hypergraph.hgdb",
_v_data: Dict[str, Any] = dict(),
_e_data: Dict[Tuple, Any] = dict(),
_v_inci: Dict[str, Set[Tuple]] = (
lambda: defaultdict(set)
)(),
)
Bases: BaseHypergraphDB
Hypergraph database.
Attributes¶
Functions¶
__post_init__ ¶
load ¶
Load the hypergraph database from the storage file.
Source code in hyperdb/hypergraph.py
save ¶
Save the hypergraph database to the storage file.
Source code in hyperdb/hypergraph.py
v ¶
Return the vertex data.
Args:
v_id
(str
): The vertex id.
default
(Any
): The default value if the vertex does not exist.
Source code in hyperdb/hypergraph.py
e ¶
Return the hyperedge data.
Args:
e_tuple
(Union[List, Set, Tuple]
): The hyperedge tuple: (v1_name, v2_name, ..., vn_name).
default
(Any
): The default value if the hyperedge does not exist.
Source code in hyperdb/hypergraph.py
encode_e ¶
Sort and check the hyperedge tuple.
Args:
e_tuple
(Union[List, Set, Tuple]
): The hyperedge tuple: (v1_name, v2_name, ..., vn_name).
Source code in hyperdb/hypergraph.py
add_v ¶
Add a vertex to the hypergraph.
Args:
v_id
(Any
): The vertex id.
v_data
(dict
, optional): The vertex data.
Source code in hyperdb/hypergraph.py
add_e ¶
Add a hyperedge to the hypergraph.
Args:
e_tuple
(Union[List, Set, Tuple]
): The hyperedge tuple: (v1_name, v2_name, ..., vn_name).
e_data
(dict
, optional): The hyperedge data.
Source code in hyperdb/hypergraph.py
remove_v ¶
Remove a vertex from the hypergraph.
Args:
v_id
(Any
): The vertex id.
Source code in hyperdb/hypergraph.py
remove_e ¶
Remove a hyperedge from the hypergraph.
Args:
e_tuple
(Union[List, Set, Tuple]
): The hyperedge tuple: (v1_name, v2_name, ..., vn_name).
Source code in hyperdb/hypergraph.py
update_v ¶
Update the vertex data.
Args:
v_id
(Any
): The vertex id.
v_data
(dict
): The vertex data.
Source code in hyperdb/hypergraph.py
update_e ¶
Update the hyperedge data.
Args:
e_tuple
(Union[List, Set, Tuple]
): The hyperedge tuple: (v1_name, v2_name, ..., vn_name).
e_data
(dict
): The hyperedge data.
Source code in hyperdb/hypergraph.py
has_v ¶
Check if the vertex exists.
Args:
v_id
(Any
): The vertex id.
has_e ¶
Check if the hyperedge exists.
Args:
e_tuple
(Union[List, Set, Tuple]
): The hyperedge tuple: (v1_name, v2_name, ..., vn_name).
Source code in hyperdb/hypergraph.py
degree_v ¶
Return the degree of the vertex.
Args:
v_id
(Any
): The vertex id.
Source code in hyperdb/hypergraph.py
degree_e ¶
Return the degree of the hyperedge.
Args:
e_tuple
(Union[List, Set, Tuple]
): The hyperedge tuple: (v1_name, v2_name, ..., vn_name).
Source code in hyperdb/hypergraph.py
nbr_e_of_v ¶
Return the incident hyperedges of the vertex.
Args:
v_id
(Any
): The vertex id.
Source code in hyperdb/hypergraph.py
nbr_v_of_e ¶
Return the incident vertices of the hyperedge.
Args:
e_tuple
(Union[List, Set, Tuple]
): The hyperedge tuple: (v1_name, v2_name, ..., vn_name).
Source code in hyperdb/hypergraph.py
nbr_v ¶
Return the neighbors of the vertex.
Args:
v_id
(Any
): The vertex id.