Storing and Serializing Graphs
We store graphs in GraphStorage objects. These objects are safely serializable
and can be indexed efficiently to retrieve PyTorch Geometric Data objects.
polygraph.datasets.base.GraphStorage
Bases: BaseModel
Serializable collection of graphs.
| Attributes: |
|
|---|
from_nx_graphs(graphs, edge_attrs=None, node_attrs=None, graph_attrs=None)
staticmethod
Construct a GraphStorage object from a sequence of NetworkX graphs.
The specified attributes must be numpy arrays and must have consistent dimensions across all graphs and nodes/edges.
| Parameters: |
|
|---|
from_pyg_batch(batch, edge_attrs=None, node_attrs=None, graph_attrs=None)
staticmethod
Construct a GraphStorage object from a PyTorch Geometric Batch object.
| Parameters: |
|
|---|
get_example(idx)
Retrieve a single graph from the collection.
| Parameters: |
|
|---|
| Returns: |
|
|---|
__len__()
Number of graphs in the collection.