gammagl.data.BatchGraph¶
- class BatchGraph(*args, **kwargs)[source]¶
Bases:
objectA data object describing a batch of graphs as one big (disconnected) graph. Inherits from
gammagl.data.Graphorgammagl.data.HeteroGraph. In addition, single graphs can be identified via the assignment vectorbatch, which maps each node to its respective graph identifier.- classmethod from_data_list(data_list: List[Graph], follow_batch: List[str] | None = None, exclude_keys: List[str] | None = None)[source]¶
Constructs a
BatchGraphobject from a Python list ofGraphorHeteroGraphobjects. The assignment vectorbatchis created on the fly. In addition, creates assignment vectors for each key infollow_batch. Will exclude any keys given inexclude_keys.
- get_example(idx: int) Graph[source]¶
Gets the
GraphorHeteroGraphobject at indexidx. TheBatchGraphobject must have been created viafrom_data_list()in order to be able to reconstruct the initial object.
- index_select(idx: slice | ndarray | Sequence) List[Graph][source]¶
Creates a subset of
GraphorHeteroGraphobjects from specified indicesidx. Indicesidxcan be a slicing object, e.g.,[2:5], a list, a tuple, or atorch.Tensorornp.ndarrayof type long or bool. TheBatchGraphobject must have been created viafrom_data_list()in order to be able to reconstruct the initial objects.
- to_data_list() List[Graph][source]¶
Reconstructs the list of
GraphorHeteroGraphobjects from theBatchGraphobject. TheBatchGraphobject must have been created viafrom_data_list()in order to be able to reconstruct the initial objects.