Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

KeyNotFoundException with MDS layout

Đang mở
#328 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
csharp
Lĩnh vực
computer-graphics

Hướng nghiên cứu

Tái hiện ngoại lệ trong GraphLayout/Samples/WpfApplicationSample/WpfApplicationSample.cs bằng MdsLayoutSettings và cấu hình subgraph được hiển thị. Bắt đầu tại phần xây dựng SimpleIntEdge, nơi nodeIndex[e.Source] và nodeIndex[e.Target] được truy cập, sau đó lần theo cách bố cục MDS xây dựng nodeIndex và xử lý subgraph2. Hoàn tất khi mẫu không còn ném KeyNotFoundException đối với bố cục này.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
C#
Star
1.5k
Fork
317
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/automatic-graph-layout

Tất cả issue của microsoft/automatic-graph-layout

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.