DDGraph

class DDGraph(graph: DGLGraph, ue_mask: Tensor | None = None, n_idx: Tensor | None = None, e_idx: Tensor | None = None)[source]

Bases: DDMixin

A wrapper around DGLGraph that supports required factory methods.

Parameters:
  • graph (dgl.DGLGraph) – The graph to wrap.

  • ue_mask (Optional[torch.Tensor], optional) – Mask indicating upper edges in the graph, by default None

  • n_idx (Optional[torch.Tensor], optional) – Tensor mapping each node to its graph index in the batch, by default None

  • e_idx (Optional[torch.Tensor], optional) – Tensor mapping each edge to its graph index in the batch, by default None

aggregate(reduction: str = 'mean') Tensor[source]

Reduce over all dimensions except batch (i.e., sum per sample).

Parameters:

reduction (str, default: "mean") – Specifies the reduction to apply: “mean” or “sum”.

Return type:

Tensor of shape (len(self),)

apply(op: Callable[[Tensor], Tensor]) Self[source]

Apply a function to the underlying tensor data (e.g., x -> -x).

classmethod collate(items: Sequence[Self]) Self[source]
combine(other: Self | float | Tensor, op: Callable[[Tensor, Tensor], Tensor]) Self[source]

Combine self with another instance element-wise (e.g., x + y).

Note: other is guaranteed to be of the same type as self because the Mixin handles scalar broadcasting before calling this.

property device: device
randn_like() Self[source]
to(device: device | str) Self[source]