liveBook · Manning

Disconnected graph

As explained in Build AI Drug Discovery Pipelines

A disconnected graph is a graph composed of separate components with no edges connecting distinct components.

A disconnected graph contains separate components with no edges between them. In graph neural network workflows, a disjoint graph combines multiple independent molecular or protein graphs without creating connections between examples. section 11.5.5

Use a disconnected graph to batch variable-size inputs efficiently:

  • Stack node features from every graph into one matrix. section 11.5.5
  • Adjust edge indices so each edge still references the correct component. section 11.5.5
  • Track each node’s original graph with a batch vector. section 11.5.5
  • Apply message passing across the combined structure, then pool nodes separately by batch index. section 11.5.5

Three molecular graphs

Batching graphs with 10, 15, and 12 atoms creates 37 nodes, a 37×78 feature matrix, and a 37-entry batch vector marking each molecule. No edges cross between molecules. section 11.5.5

from torch_geometric.data import Batch
def collate(data_list):
    batchA = Batch.from_data_list([data[-1] for data in data_list])
    batchB = Batch.from_data_list([data[0] for data in data_list])
    return batchA, batchB

Use Batch.from_data_list to combine graph objects during loading, preserving separate molecular and protein graph batches. section 11.5.5

How Build AI Drug Discovery Pipelines covers it

How deep it goes
Explains construction, node tracking, message passing, and graph-specific pooling, stopping short of implementation internals.
Examples
Uses three molecular graphs containing 10, 15, and 12 atoms, producing 37 nodes and a 37-entry batch vector.
What it assumes
Assumes graph nodes, edges, and features; develops batching for variable-size molecular and protein graphs.
What you can do after
Operate PyTorch Geometric batching for independent molecular and protein graph examples.
How it connects
Connects graph neural networks with message passing, global pooling, batch processing, molecular graphs, and protein graphs.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI Drug Discovery Pipelines. The section links point to the parts of the book it draws on.