microsoft / microsoft/automatic-graph-layout
Graph.ReadGraphFromStream ignores subgraph
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 319
- Avg merge
- 38m
- Merged PRs (30d)
- 1
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;
Contributor guide
No contributing guide indexed for this repository
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.
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.
Assessment
- Tech stack
- csharp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100