Graphviz: Node in two subgraph

╄→尐↘猪︶ㄣ 提交于 2020-07-18 07:39:47

问题


I have a graph with different clusters. Basically I want to pair different nodes i.e. show somehow that different nodes have special relationship. So I decided to use clusters so that the nodes appear in a rectangle.
The problem is that a node can be in relationship with more than one node i.e. it could be in different clusters. But I have not found out a way to insert a node in two clusters.
I have the following code:

digraph G {rankdir="LR"; 
node [fontname = "font-awesome"];
    subgraph cluster3 {
        4 -> 5 [id="4t5",color="#717070",arrowsize=.5];
        8 -> 4[id="8t4",color="#717070",arrowsize=.5];

        subgraph cluster31{
        4 [id=4,fillcolor="#F5BDA2", shape=rect;label=<<TABLE BORDER="0">
        <TR><TD>1:12</TD></TR>
        </TABLE>>, style="filled",fontsize=6,fixedsize=true,width=0.5,height=0.2,shape=Mrecord];
        5 [id=5,fillcolor="#F5BDA2", shape=ellipse;label=<<TABLE BORDER="0">
        <TR><TD ID="32e" HREF=" ">1:13</TD></TR>
        </TABLE>>, style="filled"];
        }
         subgraph cluster32{
        8 [id=8,fillcolor="#F5BDA2", shape=rect;label=<<TABLE BORDER="0">
        <TR><TD>1:19</TD></TR>
        </TABLE>>, style="filled",shape=box];
        5 [id=5,fillcolor="#F5BDA2", shape=ellipse;label=<<TABLE BORDER="0">
        <TR><TD ID="32e" HREF=" ">1:13</TD></TR>
        </TABLE>>, style="filled"];
        }
    }
}

Is there a way or a hack or another way to accomplish this idea?


回答1:


Why do you want to use the id="..." statement? It's normally not necessary.

I'm not 100% if I have you right, but if you just change only the node-name in cluster 32 from 5 to 6, and not the label, then you have the visual representation of "same" two nodes in two cluster.

For e.g.: This:

digraph G {rankdir="LR"; 
node [fontname = "font-awesome"];
    subgraph cluster3 {
        4 -> 5 [color="#717070",arrowsize=.5];
        8 -> 4[color="#717070",arrowsize=.5];

        subgraph cluster31{
        4 [fillcolor="#F5BDA2", shape=rect;label=<<TABLE BORDER="0">
        <TR><TD>1:12</TD></TR>
        </TABLE>>, style="filled",fontsize=6,fixedsize=true,width=0.5,height=0.2,shape=Mrecord];
        5 [fillcolor="#F5BDA2", shape=ellipse;label=<<TABLE BORDER="0">
        <TR><TD ID="32e" HREF=" ">1:13</TD></TR>
        </TABLE>>, style="filled"];
        }
         subgraph cluster32{
        8 [fillcolor="#F5BDA2", shape=rect;label=<<TABLE BORDER="0">
        <TR><TD>1:19</TD></TR>
        </TABLE>>, style="filled",shape=box];
        6 [fillcolor="#F5BDA2", shape=ellipse;label=<<TABLE BORDER="0">
        <TR><TD ID="32e" HREF=" ">1:13</TD></TR>
        </TABLE>>, style="filled"];
        }
    }
}

would result in that:



来源:https://stackoverflow.com/questions/49289530/graphviz-node-in-two-subgraph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!