Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

KeyNotFoundException with MDS layout

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
csharp

調査の方向性

MdsLayoutSettings と示されているサブグラフ構成を使用して、GraphLayout/Samples/WpfApplicationSample/WpfApplicationSample.cs の例外を再現します。nodeIndex[e.Source] と nodeIndex[e.Target] にアクセスしている SimpleIntEdge の構築箇所から開始し、その後、MDS レイアウトが nodeIndex をどのように構築し、subgraph2 をどのように処理するかを追跡します。このレイアウトでサンプルが KeyNotFoundException をスローしなくなれば完了です。

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

説明

Hi Lev,
I tried to modify WpfAplicationSample to show MDS layout, and it throws KeyNotFoundException.
Here are my modifications:

diff --git a/GraphLayout/Samples/WpfApplicationSample/WpfApplicationSample.cs b/GraphLayout/Samples/WpfApplicationSample/WpfApplicationSample.cs
index 5a6e6dd..f16ec58 100644
--- a/GraphLayout/Samples/WpfApplicationSample/WpfApplicationSample.cs
+++ b/GraphLayout/Samples/WpfApplicationSample/WpfApplicationSample.cs
@@ -291,6 +291,7 @@ namespace WpfApplicationSample
 //                //graph.LayoutAlgorithmSettings.EdgeRoutingSettings.EdgeRoutingMode = EdgeRoutingMode.SplineBundling;
 //                //layout the graph and draw it
                 Graph graph = new Graph();
+                graph.LayoutAlgorithmSettings=new Microsoft.Msagl.Layout.MDS.MdsLayoutSettings();
                 graph.AddEdge("47", "58");
                 graph.AddEdge("70", "71");

@@ -315,11 +316,11 @@ namespace WpfApplicationSample
                 graph.Attr.LayerDirection = LayerDirection.LR;
                 //graph.LayoutAlgorithmSettings.EdgeRoutingSettings.EdgeRoutingMode = EdgeRoutingMode.Rectilinear;

-                var global = (SugiyamaLayoutSettings) graph.LayoutAlgorithmSettings;
-                var local  = (SugiyamaLayoutSettings) global.Clone();
-                local.Transformation = PlaneTransformation.Rotation(-Math.PI / 2);
+                var global = (Microsoft.Msagl.Layout.MDS.MdsLayoutSettings) graph.LayoutAlgorithmSettings;
+                var local  = (Microsoft.Msagl.Layout.MDS.MdsLayoutSettings) global.Clone();
+                //local.Transformation = PlaneTransformation.Rotation(-Math.PI / 2);
                 subgraph2.LayoutSettings = local;   // for Collapsing\Expanding
-                global.ClusterSettings.Add(subgraph2, local);
+                //global.ClusterSettings.Add(subgraph2, local);

                 graphViewer.Graph = graph;
             }

The line, which throws exception is:

                intEdges.Add(new SimpleIntEdge {Source = nodeIndex[e.Source], Target = nodeIndex[e.Target]});

Checking with debugger, I can see that subgraph2 is missing from nodeIndex dictionary.
image
I have no idea why it happens specifically with MDS, but doesn't happen with Sugiyama.
Am I doing something wrong, or is there a bug in MDS layout algorithm?
Here's the screenshot of the exception being thrown:
image

主要言語
C#
スター
1.5k
フォーク
317
PR マージ指標
30日以内にマージされた PR はありません

環境構築

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

はじめの一歩

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

microsoft/automatic-graph-layout のほかの issue

microsoft/automatic-graph-layout の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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