【问题标题】:How do I graph the Thompson's construction using graphviz?如何使用 graphviz 绘制 Thompson 的构造图?
【发布时间】:2020-03-08 09:39:35
【问题描述】:

我正在尝试使用 graphviz 绘制 Thompson 的构造图,我想知道是否有人可以帮助我绘制其中一条规则,以便我可以执行其他规则。

我附上一张参考图:https://en.wikipedia.org/wiki/Thompson%27s_construction#/media/File:Thompson-kleene-star.svg

digraph finite_state_machine {
    rankdir=LR;
    size="8,5"
    node [shape = doublecircle]; s3;
    node [shape = circle];
    s0 -> s1 [ label = "ε" ];   
    s0 -> s3 [ label = "ε" ];
    s1 -> s2 [ label = "ε" ];
    s2 -> s1 [ label = "ε" ];
    s2 -> s3 [ label = "ε" ];
}

【问题讨论】:

  • 欢迎来到 Stack Overflow。请向我们展示您迄今为止所做的努力,以便我们可以帮助您解决问题。
  • 我已经上传了我所做的事情
  • graphviz 代码的输出有什么问题?
  • 设计不一样
  • 杜尔 - 我猜到了 - 但要具体一点,例如,您可以附上它产生的图像。

标签: graph graphviz


【解决方案1】:

Graphviz 程序尽量避免将节点置于其他节点之上。您可以通过为所有节点显式提供 pos 属性来获取节点位置。 (没那么难,但很麻烦。)您可以让 neato 生成所有直边,但您必须为所有弧提供(样条)坐标。否则你会得到这个:

作为替代方案,如果您使用 dpic 或 gpic,请使用此程序,而不是 graphviz:

.PS

.defcolor pink rgb #FFC0CB
 circlerad=circlerad*.8

 ## we need to place the large oval before we place nodes on it
 Qx: circle invis ; line invis; circle invis; A: line invis; 
 ellipseht=ellipseht*2;  
 ellipsewid=ellipsewid*2
 E:ellipse at  A.c   shaded "pink" " N(s)"

 move to Qx.w 

 Q: circle "q" ; arrow "ε" "";  C1: circle ; A: line invis; C2: circle ; arrow "ε" "";  F: circle "f"; 

 circlerad=circlerad*.8
 F1:circle   at last circle   

 move to E.n; up; P1: box invis "ε"
 arc -> from C2.n to C1.n 

 arcrad=2
 arc -> from Q.s to F.s

  ### gpic version of greek chars:
  # move to E.s; down; box invis "" "\[*e]"
  ########################################

  ###  dpic/svg version of greek chars
  move to E.s; down; box invis "" "ε"

.PE

产生了这个:

gpic 是 GNU (Linux) groff 软件包的一部分。
dpic 可以在这里找到:https://ece.uwaterloo.ca/~aplevich/dpic/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-27
    • 1970-01-01
    • 2019-10-27
    • 2017-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-09
    • 2018-04-03
    相关资源
    最近更新 更多