Skip to content

Fix #46 #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix #46 #57

wants to merge 2 commits into from

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,)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant