BaseHypergraphDB Class¶
hyperdb.base.BaseHypergraphDB
dataclass
¶
Base class for hypergraph database.
Attributes¶
storage_file
class-attribute
instance-attribute
¶
Functions¶
save ¶
Save the hypergraph to a file.
Args:
file_path
(Union[str, Path]
): The file path to save the hypergraph.
save_as ¶
Save the hypergraph to a specific format.
Args:
format
(str
): The export format (e.g., "json", "csv", "graphml").
file_path
(Union[str, Path]
): The file path to export the hypergraph.
Source code in hyperdb/base.py
load
staticmethod
¶
Load the hypergraph from a file.
Args:
file_path
(Union[str, Path]
): The file path to load the hypergraph from.
load_from ¶
Load a hypergraph from a specific format.
Args:
format
(str
): The import format (e.g., "json", "csv", "graphml").
file_path
(Union[str, Path]
): The file path to import the hypergraph from.
Source code in hyperdb/base.py
v ¶
Return the vertex data.
Args:
v_id
(Any
): The vertex id.
default
(Any
): The default value if the vertex does not exist.
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/base.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).
add_v ¶
Add a vertex to the hypergraph.
Args:
v_id
(Any
): The vertex id.
v_data
(Dict
, optional): The vertex data. Defaults to None.
Source code in hyperdb/base.py
add_e ¶
Add a hyperedge to the hypergraph.
Args:
e_tuple
(Tuple
): The hyperedge tuple: (v1_name, v2_name, ..., vn_name).
e_data
(Dict
, optional): The hyperedge data.
Source code in hyperdb/base.py
remove_v ¶
remove_e ¶
Remove a hyperedge from the hypergraph.
Args:
e_tuple
(Tuple
): The hyperedge tuple: (v1_name, v2_name, ..., vn_name).
update_v ¶
update_e ¶
Update the hyperedge data.
Args:
e_tuple
(Tuple
): The hyperedge tuple: (v1_name, v2_name, ..., vn_name).
has_v ¶
Return True if the vertex exists in the hypergraph.
Args:
v_id
(Any
): The vertex id.
has_e ¶
Return True if the hyperedge exists in the hypergraph.
Args:
e_tuple
(Tuple
): The hyperedge tuple: (v1_name, v2_name, ..., vn_name).
degree_v ¶
degree_e ¶
Return the degree of the hyperedge.
Args:
e_tuple
(Tuple
): The hyperedge tuple: (v1_name, v2_name, ..., vn_name).
nbr_e_of_v ¶
Return the hyperedge neighbors of the vertex.
Args:
v_id
(Any
): The vertex id.
nbr_v_of_e ¶
Return the vertex neighbors of the hyperedge.
Args:
e_tuple
(Tuple
): The hyperedge tuple: (v1_name, v2_name, ..., vn_name).
nbr_v ¶
sub ¶
Return the sub-hypergraph.
Args:
v_name_list
(List[str]
): The list of vertex ids.
sub_from_v ¶
Return the sub-hypergraph from the vertex.
Args:
v_id
(Any
): The vertex id.
depth
(int
): The depth of the sub-hypergraph.
query_v ¶
Query and return vertices that match the given filters.
Args:
filters
(Dict[str, Any]
): A dictionary of conditions to filter vertices.
query_e ¶
Query and return hyperedges that match the given filters.
Args:
filters
(Dict[str, Any]
): A dictionary of conditions to filter hyperedges.
Source code in hyperdb/base.py
stats ¶
draw ¶
Draw the hypergraph data of the current HyperDB instance
Args:
port
: Server port number, defaults to 8080
open_browser
: Whether to automatically open the browser, defaults to True
blocking
: Whether to block the main thread, defaults to True. Set to False for non-blocking mode.
Returns: HypergraphViewer instance