gammagl.data.BaseGraph¶
- class BaseGraph[source]¶
Bases:
object
- to_namedtuple() NamedTuple [source]¶
Returns a
NamedTuple
of stored key/value pairs.
- __cat_dim__(key: str, value: Any, *args, **kwargs) Any [source]¶
Returns the dimension for which the value
value
of the attributekey
will get concatenated when creating mini-batches usinggammagl.loader.DataLoader
.Note
This method is for internal use only, and should only be overridden in case the mini-batch creation process is corrupted for a specific attribute.
- __inc__(key: str, value: Any, *args, **kwargs) Any [source]¶
Returns the incremental count to cumulatively increase the value
value
of the attributekey
when creating mini-batches usinggammagl.loader.DataLoader
.Note
This method is for internal use only, and should only be overridden in case the mini-batch creation process is corrupted for a specific attribute.
- property num_nodes: int | None¶
Returns the number of nodes in the graph.
Note
The number of nodes in the data object is automatically inferred in case node-level attributes are present, e.g.,
data.x
. In some cases, however, a graph may only be given without any node-level attributes. GammaGL then guesses the number of nodes according toedge_index.max().item() + 1
. However, in case there exists isolated nodes, this number does not have to be correct which can result in unexpected behaviour. Thus, we recommend to set the number of nodes in your data object explicitly viagraph.num_nodes = ...
. You will be given a warning that requests you to do so.
- size(dim: int | None = None) Tuple[int | None, int | None] | int | None [source]¶
Returns the size of the adjacency matrix induced by the graph.
- property num_edges: int¶
Returns the number of edges in the graph. For undirected graphs, this will return the number of bi-directional edges, which is double the amount of unique edges.
- is_coalesced() bool [source]¶
Returns
True
if theedge_index
is sorted and does not contain duplicate entries.
- apply_(func: Callable, *args: List[str])[source]¶
Applies the in-place function
func
, either to all attributes or only the ones given in*args
.