harshsikhwal / csdot

A c# based DOT (graphviz) framework
https://graphviz.org/resources/
MIT License
32 stars 6 forks source link

Cluster does not save in the correct format #35

Closed Bambofy closed 3 years ago

Bambofy commented 3 years ago

Bug: Using the cluster object instead of a subgraph object has no effect.

Code:

                    Graph g = new Graph();
                    g.type = "digraph";
                    g.Attribute.compound.Set = true;
                    g.Attribute.compound.Value = true;

                    Cluster cl1 = new Cluster("cl1");
                    Cluster cl2 = new Cluster("cl2");
                    g.AddElement(cl1);
                    g.AddElement(cl2);

                    Node n1 = new Node("n1");
                    Node n2 = new Node("n2");
                    cl1.AddElement(n1);
                    cl2.AddElement(n2);

                    Edge edge = new Edge();
                    List<Transition> transitions = new List<Transition>()
                    {
                        new Transition(n1, "->"),
                        new Transition(n2, "")
                    };
                    edge.Transition = transitions;

                    g.AddElement(edge);

                    DotDocument doc = new DotDocument();
                    doc.SaveToFile(g, "dotdoc");

Results in:

digraph 
{
    compound = True
    subgraph cl1
    {
        n1;
    }
    subgraph cl2
    {
        n2;
    }
    n1 -> n2 
}

It should result in:

digraph 
{
    compound = True
    subgraph cluster_cl1
    {
        n1;
    }
    subgraph cluster_cl2
    {
        n2;
    }
    n1 -> n2 
}

(note the cluser_ prefix on the id)

harshsikhwal commented 3 years ago

Thanks for this. We will get back with a fix.

Vibaswan commented 3 years ago

We have fixed the issue, it will be propagated in the next release