mariusz-schimke / GiGraph

Simple yet versatile library for generating graphs in the DOT language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

clusters to have rank as a property

gabrieldelaparra opened this issue · comments

Heya, very cool library.

Currently I am adding rank to a cluster using the following:

var cluster = new DotCluster(givenId);
cluster.Attributes.Add("rank", new DotStringAttribute("rank", "same"));

Is this the right way?
I could not find any property available for this.

Hey Gabriel!

Thanks, I’m glad you like it! Regarding the rank attribute, every element of the graph has only those attributes exposed, that the Graphviz documentation says is supported by it. You are trying to add a rank attribute to a cluster, but according to the docs, it is supported by subgraphs only. Actually a cluster is a special type of subgraph, but the documentation indicates that rank is valid only for the “normal” subgraphs.

Therefore you should rather do it this way:

var subgraph = new DotSubgraph(DotRank.Same);

or simply

var subgraph = graph.Subgraphs.Add(DotRank.Same);

(check also the overloads of the Add method).

Also, a “normal” subgraph may have an ID, but I don’t think it is actually used. Please correct me if I’m wrong (I’m not an expert).

See also my examples here, in the subgraphs section, and in the clusters section too, so you know the difference between these two elements. Both the sections contain links to examples so you can learn how a cluster is visualized as opposed to a subgraph.

Please let me know if the answer solves your problem.