【问题标题】:Graphviz: Node in two subgraphGraphviz:两个子图中的节点
【发布时间】:2018-08-23 16:16:51
【问题描述】:

我有一个包含不同集群的图表。基本上我想配对不同的节点,即以某种方式显示不同的节点具有特殊的关系。所以我决定使用集群,让节点出现在一个矩形中。
问题是一个节点可能与多个节点有关系,即它可能在不同的集群中。但是我还没有找到在两个集群中插入节点的方法。
我有以下代码:

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"];
        }
    }
}

有没有办法或黑客或其他方式来实现这个想法?

【问题讨论】:

    标签: graphviz dot subgraph


    【解决方案1】:

    为什么要使用 id="..." 语句?通常不需要。

    如果我说得对,我不是 100%,但如果您只是将集群 32 中的节点名称从 5 更改为 6,而不是标签,那么您将获得“相同”两个节点的视觉表示在两个集群中。

    例如:这个:

    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"];
            }
        }
    }
    

    会导致:

    【讨论】:

      猜你喜欢
      • 2020-03-25
      • 1970-01-01
      • 1970-01-01
      • 2021-03-20
      • 1970-01-01
      • 2011-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多