src/graphnet/components/pool.py
def sum_pool(cluster, data, transform=None):
    r"""Pools and coarsens a graph given by the
    :class:`torch_geometric.data.Data` object according to the clustering
    defined in :attr:`cluster`.
    All nodes within the same cluster will be represented as one node.
    Final node features are defined by the *sum* of features of all nodes
    within the same cluster, node positions are averaged and edge indices are
    defined to be the union of the edge indices of all nodes within the same
    cluster.

    Args:
        cluster (LongTensor): Cluster vector :math:`\mathbf{c} \in \{ 0,
            \ldots, N - 1 \}^N`, which assigns each node to a specific cluster.
        data (Data): Graph data object.
        transform (callable, optional): A function/transform that takes in the
            coarsened and pooled :obj:`torch_geometric.data.Data` object and
            returns a transformed version. (default: :obj:`None`)

    :rtype: :class:`torch_geometric.data.Data`
    """
    cluster, perm = consecutive_cluster(cluster)

    x = None if data.x is None else _sum_pool_x(cluster, data.x)
    index, attr = pool_edge(cluster, data.edge_index, data.edge_attr)
    batch = None if data.batch is None else pool_batch(perm, data.batch)
    pos = None if data.pos is None else pool_pos(cluster, data.pos)

    data = Batch(batch=batch, x=x, edge_index=index, edge_attr=attr, pos=pos)

    if transform is not None:
        data = transform(data)

    return data
r"""Pools and coarsens a graph given by the
    :class:`torch_geometric.data.Data` object according to the clustering
    defined in :attr:`cluster`.
    All nodes within the same cluster will be represented as one node.
    Final node features are defined by the *sum* of features of all nodes
    within the same cluster, node positions are averaged and edge indices are
    defined to be the union of the edge indices of all nodes within the same
    cluster.

    Args:
        cluster (LongTensor): Cluster vector :math:`\mathbf{c} \in \{ 0,
            \ldots, N - 1 \}^N`, which assigns each node to a specific cluster.
        data (Data): Graph data object.
        transform (callable, optional): A function/transform that takes in the
            coarsened and pooled :obj:`torch_geometric.data.Data` object and
            returns a transformed version. (default: :obj:`None`)

    :rtype: :class:`torch_geometric.data.Data`
    
r"""Pools and coarsens a graph given by the
:class:`torch_geometric.data.Data` object according to the clustering
defined in :attr:`cluster`.
All nodes within the same cluster will be represented as one node.
Final node features are defined by the *sum* of features of all nodes
within the same cluster, node positions are averaged and edge indices are
defined to be the union of the edge indices of all nodes within the same
cluster.
r " " " Pools and coarsens a graph given by the : class : ` torch_geometric . data . Data ` object according to the clustering defined in : attr : ` cluster ` . All nodes within the same cluster will be represented as one node . Final node features are defined by the * sum * of features of all nodes within the same cluster node positions are averaged and edge indices are defined to be the union of the edge indices of all nodes within the same cluster .
def sum_pool(cluster, data, transform=None):
    cluster, perm = consecutive_cluster(cluster)
    x = None if data.x is None else _sum_pool_x(cluster, data.x)
    index, attr = pool_edge(cluster, data.edge_index, data.edge_attr)
    batch = None if data.batch is None else pool_batch(perm, data.batch)
    pos = None if data.pos is None else pool_pos(cluster, data.pos)
    data = Batch(batch=batch, x=x, edge_index=index, edge_attr=attr, pos=pos)
    if transform is not None:
        data = transform(data)
    return data
def sum_pool ( cluster , data , transform = None ) : cluster , perm = consecutive_cluster ( cluster ) x = None if data . x is None else _sum_pool_x ( cluster , data . x ) index , attr = pool_edge ( cluster , data . edge_index , data . edge_attr ) batch = None if data . batch is None else pool_batch ( perm , data . batch ) pos = None if data . pos is None else pool_pos ( cluster , data . pos ) data = Batch ( batch = batch , x = x , edge_index = index , edge_attr = attr , pos = pos ) if transform is not None : data = transform ( data ) return data
r"""Pools and coarsens a graph given by the
:class:`torch_geometric.data.Data` object according to the clustering
defined in :attr:`cluster`.
r " " " Pools and coarsens a graph given by the : class : ` torch_geometric . data . Data ` object according to the clustering defined in : attr : ` cluster ` .
r"""Pools and coarsens a graph given by the
    :class:`torch_geometric.data.Data` object according to the clustering
    defined in :attr:`cluster`.
    All nodes within the same cluster will be represented as one node.
    Final node features are defined by the *sum* of features of all nodes
    within the same cluster, node positions are averaged and edge indices are
    defined to be the union of the edge indices of all nodes within the same
    cluster.

    Args:
        cluster (LongTensor): Cluster vector :math:`\mathbf{c} \in \{ 0,
            \ldots, N - 1 \}^N`, which assigns each node to a specific cluster.
        data (Data): Graph data object.
        transform (callable, optional): A function/transform that takes in the
            coarsened and pooled :obj:`torch_geometric.data.Data` object and
            returns a transformed version. (default: :obj:`None`)

    :rtype: :class:`torch_geometric.data.Data`
    """
cluster
Cluster vector :math:`\mathbf{c} \in \{ 0,
\ldots, N - 1 \}^N`, which assigns each node to a specific cluster.
Cluster vector : math : ` \ mathbf { c } \ in \ { 0 \ ldots N - 1 \ } ^N ` which assigns each node to a specific cluster .
data
Graph data object.
Graph data object .
transform
A function/transform that takes in the
coarsened and pooled :obj:`torch_geometric.data.Data` object and
returns a transformed version. (default: :obj:`None`)
A function / transform that takes in the coarsened and pooled : obj : ` torch_geometric . data . Data ` object and returns a transformed version . ( default : : obj : ` None ` )