dbgnn
Utils for DBGNN models.
generate_bipartite_edge_index
¶
Generate edge_index for bipartite graph connecting nodes of a second-order graph to first-order nodes.
The mapping strategy determines to which first-order nodes the second-order nodes are connected: - "last": Connects each second-order node to the last node in its sequence. - "first": Connects each second-order node to the first node in its sequence. - "both": Connects each second-order node to both the first and last nodes in its sequence.
Only for Second-Order Graphs
This function is intended to be used with second-order graphs only. It does not support the use of higher-order graphs, such as third-order graphs or beyond.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
g
|
pathpyG.core.graph.Graph
|
The first-order graph. |
required |
g2
|
pathpyG.core.graph.Graph
|
The second-order graph. |
required |
mapping
|
str
|
The mapping strategy to use. Options are "last", "first", or "both". Defaults to "last". |
'last'
|
device
|
torch.device
|
The device to place the tensor on. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
torch.Tensor
|
torch.Tensor: The edge_index tensor for the bipartite graph. |