PyG Exporter
Module that defines the export of polyhex graphs to a PyGeometric Hetero Data object
- class polyhex.objects.exporters.pyg_exporter.PyGExporter
Bases:
objectPyGExporter class: interface between polyhex graphs and PyGeometric graphs
- export_graph(graph: Graph)
Factory function to extract a graph
- Parameters:
graph (
Graph) – Graph object. It must have a name, a number of nodes n_nodes, and nodes, weights, node_to_index dicts.- Raises:
NotImplementedError – there is no unique way to export a graph. As polyhex aims to be modular, it will throw a NotImplementedError if a graph.name has no matching condition explicitely added here.
- Returns:
A PyGeometric Data object (https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.data.Data.html)
- Return type:
Data
- export_graphs(graphs: Dict[str, Graph])
Exports a dict of Graphs
- Parameters:
graphs (
Dict[str,Graph]) – A dictionnary holding the graphs- Returns:
A PyGeometric HeteroData object (https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.data.HeteroData.html)
- Return type:
HeteroData
- template_exporter(graph: Graph, distance_kwd: str, record_y=False)
Template function to export a graph to PyG
- Parameters:
graph (
Graph) – Graph object. It must have nodes, weights and node_to_index dicts.distance_kwd (
str) – the string identifier of the distance function.record_y (
bool, optional) – Whether or not to record the spatial position of the nodes. As it is ambiguous for the edges, it is not a default parameter of the template. Defaults to False.
- Returns:
A PyGeometric Data object (https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.data.Data.html)
- Return type:
Data