Graph.ReadGraphFromStream ignores subgraph
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- csharp
- Domain
- computer-graphics
Research direction
Start by reproducing the provided example with Graph.WriteToStream and Graph.ReadGraphFromStream, then inspect how the lone subgraph is reconstructed before assigning the result to gViewer.Graph. Compare this with the temporary-subgraph workaround. Done means a graph containing one subgraph renders that subgraph in gViewer after a stream round trip.
Written by the indexing model from the issue text.
Description
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;
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 319
- PR merge metrics
- No merged PRs in 30d
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/automatic-graph-layout
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
microsoft/automatic-graph-layout#395 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Issue with framework reference in the GraphViewerGDI.nuspecMay be free again @levnach claimed this 257 days ago, and no pull request is open. Open
microsoft/automatic-graph-layout#390 · 6 comments · 2 reactions · 2 assignees ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
microsoft/automatic-graph-layout#389 · 1 comment · 1 reaction ·
All issues in microsoft/automatic-graph-layout
Similar issues
-
copilot documentation
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 2 days
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 4 days
-
needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
spectreconsole/spectre.console#2221 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
godotengine/godot-docs#12428 ·
Maintainers usually reply within 1 day