【问题标题】:How to nest points (shapes) inside a circle (shape)?如何在圆(形状)内嵌套点(形状)?
【发布时间】:2015-01-05 20:44:24
【问题描述】:

我很想去:

我尝试对此类图表进行变体:

digraph G {
    node [shape=circle penwidth=2 fixedsize=true label=""]
    token [shape=point ]
    place [ xlabel="P2" _background="digraph G { e[shape=point ] }"]
}

this online form 中可测试导致:

我应该怎么做才能将一个点 (token) 放在一个圆圈 (place) 内

【问题讨论】:

    标签: graphviz petri-net


    【解决方案1】:

    Graphviz 程序通常不喜欢故意将节点放置在其他节点之上,但在特殊情况下允许这样做 - neato -nneato -n2 允许这样做(请参阅常见问题解答)。

    我向这个输入文件添加了一个新属性(dotme):

    digraph G {
        node [shape=circle penwidth=2  label=""]
        n1 [ xlabel="P1" dotme=1]
        n2 [ xlabel="P2" ]
        n3 [ xlabel="P3" dotme=1]
      
        n1 -> n2
        n1 -> n3
        n2 -> n3
    }
    

    然后通过这组 Graphviz 程序运行它:

    dot -Tdot needsadot.gv |gvpr -c -fdotMe.gvpr |neato -n2 -Tpng >needsadot.png
    

    gvpr 程序 dotMe.gvpr 在这里:

    BEGIN {
    
      int nxt=0;
    
    }
    N {
      int i;
      string str1, str2;
      node_t n;
    
      if (hasAttr($, "dotme")){
        if (strcmp($.dotme,"1")==0){
          // create a new node and position it on top of existing node
          str1=sprintf("__dot_%d", ++nxt);
          n=node($G, str1);
          n.pos=$.pos;
          n.shape="point";
        }
      }
    }
    

    dotMe.gvpr 在 dotme==1 的每个节点(相同的 pos)之上添加一个新节点。
    复杂,但可重复使用。

    【讨论】:

    • 不会n1 [ xlabel="P1" label="."]做类似的事情,点有点细,但也许有一些可能扩大它。
    【解决方案2】:

    Albert 的想法(使用 unicode 符号)效果很好(使用点大小来改变点大小):

    digraph G {
        node [shape=circle penwidth=2  label=""]
        n1 [ xlabel="P1" label=<<font point-size="8">&#9899;</font>>]
        n2 [ xlabel="P2" ]
        n3 [ xlabel="P3" label=<<font point-size="6">&#9899;</font>>]
      
        n1 -> n2
        n1 -> n3
        n2 -> n3
    }
    

    给出了这个:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-18
      • 2012-07-09
      • 2015-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多