add_nodes and add_edges leave graph_indicator inconsistent on batched graphs

オープン
#733 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
julia
領域
backend, data

調査の方向性

Read GNNGraphs/src/transform.jl, focusing on add_nodes and add_edges, and compare their handling of graph_indicator with the remove_nodes fix in PR #717. Decide or confirm the intended semantics for assigning new nodes in a batched graph, then check that the indicator stays consistent and sorted. Done when the chosen behavior is documented and tests cover batched additions, including the reported examples.

索引モデルが issue の本文から書いたものです。

説明

gnngraphs

add_nodes and add_edges (when the new edges reference nodes beyond num_nodes) increase num_nodes but pass g.graph_indicator through unchanged. On a batched graph this leaves graph_indicator shorter than num_nodes:

using GNNGraphs
g = batch([rand_graph(3, 4), rand_graph(4, 6)])
g.num_nodes, length(g.graph_indicator)              # (7, 7)

g1 = add_nodes(g, 2)
g1.num_nodes, length(g1.graph_indicator)            # (9, 7)

g2 = add_edges(g, [8], [1])
g2.num_nodes, length(g2.graph_indicator)            # (8, 7)

The resulting graph is inconsistent, so functions relying on graph_indicator (e.g. unbatch, getgraph, graph-level pooling) are likely to misbehave or error on it. The relevant code is add_nodes and add_edges in GNNGraphs/src/transform.jl, which both build the new GNNGraph with g.graph_indicator.

It's not a one-line fix because the correct behavior is ambiguous: it's unclear which graph of the batch the new nodes belong to. Options:

  1. Add a keyword (e.g. graph = ...) to assign the new nodes to an existing graph, extending graph_indicator accordingly (and keeping it sorted, which unbatch requires).
  2. Allow the new nodes to be appended as a new graph.
  3. Throw an informative error for batched graphs (g.num_graphs > 1) until the semantics are decided.

Found while reviewing #717, which fixes the same class of inconsistency for remove_nodes.

🧔‍♂️🤖 Assisted by AI

主要言語
Julia
スター
310
フォーク
75
平均マージ
2日 15時間
マージ済み PR(30日)
10

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

JuliaGraphs/GraphNeuralNetworks.jl のほかの issue

JuliaGraphs/GraphNeuralNetworks.jl の issue をすべて見る

似ている issue

Julia の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。