easygraph.datasets.hypergraph.contact_primary_school module#
- class easygraph.datasets.hypergraph.contact_primary_school.contact_primary_school(data_root=None)[source]#
Bases:
object
A class for loading and processing the primary school contact network hypergraph dataset.
This class loads hyperedge, node label, and label name data from specified URLs and generates a hypergraph.
- data_root#
The root URL for the data. If not provided, it is set to None.
- Type:
str
- hyperedges_path#
The URL for the hyperedge data.
- Type:
str
- node_labels_path#
The URL for the node label data.
- Type:
str
- label_names_path#
The URL for the label name data.
- Type:
str
- _hyperedges#
A list storing hyperedges.
- Type:
list
- _node_labels#
A list storing node labels.
- Type:
list
- _label_names#
A list storing label names.
- Type:
list
- _node_names#
A list storing node names (currently unused).
- Type:
list
- _content#
A dictionary containing dataset statistics and data.
- Type:
dict
- generate_hypergraph(hyperedges_path=None, node_labels_path=None, label_names_path=None)[source]#
Generates hypergraph data from specified URLs.
- Parameters:
hyperedges_path (str, optional) – The URL for the hyperedge data. Defaults to None.
node_labels_path (str, optional) – The URL for the node label data. Defaults to None.
label_names_path (str, optional) – The URL for the label name data. Defaults to None.
- property hyperedges#
Gets the list of hyperedges.
- Returns:
A list of hyperedges.
- Return type:
list
- property label_names#
Gets the list of label names.
- Returns:
A list of label names.
- Return type:
list
- property node_labels#
Gets the list of node labels.
- Returns:
A list of node labels.
- Return type:
list
- process_label_txt(data_str, delimiter='\n', transform_fun=<class 'str'>)[source]#
Processes label data read from a text file.
- Args:
data_str (str): A string containing label data. delimiter (str, optional): The delimiter used to split the string. Defaults to “
- “.
transform_fun (callable, optional): A function used to transform each label. Defaults to str.
- Returns:
list: A list of processed labels.
- easygraph.datasets.hypergraph.contact_primary_school.request_text_from_url(url)[source]#
Requests text data from the specified URL.
- Parameters:
url (str) – The URL from which to request data.
- Returns:
The text content of the response if the request is successful.
- Return type:
str
- Raises:
EasyGraphError – If a connection error occurs or the HTTP response status code indicates failure.