Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Conversation

Subhiiiiii
Copy link

Fix: Handle None senders/receivers in GCN when add_self_edges=True

Problem

The GCN implementation would fail when:

  1. The graph had no edges (senders and receivers are None)
  2. add_self_edges=True was set

This occurred because jnp.concatenate() was called with None values:

conv_receivers = jnp.concatenate((receivers, jnp.arange(total_num_nodes)), axis=0)  # fails when receivers is None

Solution

Added explicit handling of None values by converting them to empty arrays:

if senders is None:
    senders = jnp.array([], dtype=jnp.int32)
if receivers is None:
    receivers = jnp.array([], dtype=jnp.int32)

Impact

  • Fixes: Enables GCN to work with edgeless graphs when add_self_edges=True
  • Consistency: Maintains same behavior for graphs with/without edges
  • Robustness: More type-safe implementation
  • Backward Compatible: No changes to existing functionality for graphs with edges

Example

For a 3-node graph with no edges:

# Before (would crash):
senders = None
receivers = None

# After (works correctly):
senders = jnp.array([], dtype=jnp.int32)  # shape (0,)
receivers = jnp.array([], dtype=jnp.int32)  # shape (0,)

Copy link

google-cla bot commented Mar 31, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant