Skip to content

Graph.Read ignores subgraph in Wpf #376

@TihonchukArtyom89

Description

@TihonchukArtyom89

Hi! I am create a graph add nodes and edges, and put some nodes in a subgraph. Then I am write this graph to *.msagl file and open with Graph.Read from this file and bind it to DockPanel. It display graph with all nodes and edges, but without subgraph.
Code:

      GraphViewer graphViewer = new GraphViewer();
      Graph graph = new();
      graphViewer.BindToPanel(graphViewerPanel);
      var a =graph.AddNode("A");
      var b = graph.AddNode("B");
      var c = graph.AddNode("C");
      var d = graph.AddNode("D");
      var f = graph.AddNode("F");
      b.Attr.Shape = Shape.Hexagon;
      var ab = graph.AddEdge(a.Id, b.Id);
      var fc = graph.AddEdge(f.Id, c.Id);
      var da = graph.AddEdge(d.Id, a.Id);
      var fa = graph.AddEdge(a.Id, f.Id);
      var s = new Subgraph("sub_Id");
      s.Attr.Color = Microsoft.Msagl.Drawing.Color.Red;
      s.Attr.FillColor = Microsoft.Msagl.Drawing.Color.Green;
      s.Attr.Shape = Shape.Box;
      s.Label.FontColor=Microsoft.Msagl.Drawing.Color.Black;
      s.Label.Text = "text subgraph";
      s.AddNode(a);
      s.AddNode(d);
      s.AddNode(f);
      graph.RootSubgraph.AddSubgraph(s);
      graph.Write("test_graph_with_subgraph.msagl");
      graph = Graph.Read("test_graph_with_subgraph.msagl");
      graphViewer.Graph = graph;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions