Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Graph.ReadGraphFromStream ignores subgraph

未关闭
#330 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
csharp

调研方向

首先使用 Graph.WriteToStream 和 Graph.ReadGraphFromStream 重现提供的示例,然后检查唯一的子图在将结果赋给 gViewer.Graph 之前是如何重建的。将其与临时子图的变通方案进行比较。当包含一个子图的图经过流往返后能在 gViewer 中渲染该子图时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

When only 1 subgraph is present in an XML stream the subgraph is not rendered in gviewer. The current workaround i've been using is to add a temporary subgraph before writing the graph to XML, then removing the temporary subgraph after reading the XML into a graph

See code for example

        Graph graph = new Graph("graph");
        var node1 = new Node("test1");
        graph.AddNode(node1);

        var subgraph = new Subgraph("subgraph1");
        graph.RootSubgraph.AddSubgraph(subgraph);
        subgraph.AddNode(node1);

        //uncommenting the next 2 lines will make subgraph1 appear. If left uncommented, subgraph1 will not appear
        //var subgraph2 = new Subgraph("delete") { IsVisible = false }; //IsVisible is not carried over in stream
        //graph.RootSubgraph.AddSubgraph(subgraph2);

        //write graph to xml
        string xml;
        using (var stream1 = new MemoryStream()) {
            graph.WriteToStream(stream1);
            stream1.Position = 0;
            using (var streamReader = new StreamReader(stream1)) {
                xml = streamReader.ReadToEnd();
            } 
        }

        //read graph from xml
        using (var stream = new MemoryStream()) {
            using (var streamWriter = new StreamWriter(stream)) {
                streamWriter.Write(xml);
                streamWriter.Flush();//otherwise you are risking empty stream
                stream.Position = 0;
                graph = Graph.ReadGraphFromStream(stream);
            }
        }

        //graph.RootSubgraph.RemoveSubgraph(graph.RootSubgraph.Subgraphs.Where(x => x.Id == "delete").FirstOrDefault());
        

        gViewer.Graph = graph;
主要语言
C#
星标
1.5k
派生
318
平均合并
4 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/automatic-graph-layout 的其他 Issue

查看 microsoft/automatic-graph-layout 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。