Number: 414
Title: rank and cluster works only if nodes are referenced in specific order!
Submitter: Mehrdad Reshadi
Date: Tue Mar 2 23:43:03 2004
Subsys: Dot
Version: 1.10
System: *-*-*
Severity: major
Problem:
I have some clusters and want to arrange them based on some nodes outside of them. The rank of the cluster can be adjusted by using the {rank=same;...} command. However, only a special order of rank commands works. In the following example, I have 3 clusters containing some random graph. Suppose the I want to adjust all of them with node K_2 in the outer cluster. If I use case1 or case3 in the example, all clustered will be placed at the top of the diagram. But if I use case2, it works. However, it works only if I set the rank of K_2 and the last cluster, then the last cluster and the one before, and so on. The results are the same on both WindowsXP and Red Hat Linux 9.
Input:
digraph test {
	clusterrank=local

	subgraph cluster_X
	{
		label="first"

		subgraph cluster_I
		{
			label="[0..1]"
			"I0"
			node [shape=circle]
			"I_0" [label="0"]
		}
		subgraph cluster_O
		{
			label="[1..4]"

			"O0" -> "O4"
			"O1" -> "O0"
			"O2" -> "O3"
			"O3" -> "O0"
			"O4" -> "O5"

			node [shape=circle]
			"O_0" [label="0"]
			"O_1" [label="1"]
			"O_2" [label="2"]
			"O_0" -> "O_1" -> "O_2"
		}

		subgraph cluster_Y
		{
			label="[1..2]"
			"Y0" -> { "Y1"; "Y2";}

			node [shape=circle]
			"Y_0" [label="0"]
			"Y_1" [label="1"]
			"Y_0" -> "Y_1"
		}

		node [shape=circle]
		"K_0" [label="0"]
		"K_1" [label="1"]
		"K_2" [label="2"]
		"K_3" [label="3"]
		 "K_0" -> "K_1" -> "K_2" -> "K_3"

		/*case 1: does not work correctly * /
		{rank=same; "K_2";"I_0";}
		{rank=same; "K_2";"O_0";}
		{rank=same; "K_2";"Y_0";}
		/ **/

		/*case 2: works correcly on if the order is from last cluster to the first */
		{rank=same; "O_0";"I_0";}
		{rank=same; "Y_0";"O_0";}
		{rank=same; "K_2";"Y_0";}
		/**/

		/*case 3: does not correcly because the order of ranks is different* /
		{rank=same; "Y_0";"O_0";}
		{rank=same; "O_0";"I_0";}
		{rank=same; "K_2";"Y_0";}
		/ **/
	}
}
Comments:
[north] It's worse than that - in general, they don't work together at all. Because rank=same and clusters both use similar mechanisms of node collapsing during the level assignment phase, it's not possible to assign the same rank to nodes in two different clusters. It's not an unreasonable thing to want.
Owner: *
Status: *