2016-11-11 80 views
1

我試圖複製使用Graphviz的這一數字列(在LaTeX中生成的數字):enter image description here定影節點到使用的graphviz

做各種搜索和閱讀,我已經成功遠遠得到這個:

enter image description here

我對獲取超級和下標不感興趣。如果我真的想要的話,我很確定我能確定這一點。我想要做的是確保節點都在3 x 3網格中,並且很好地對齊。正如你所看到的,我的產品沒有對齊。我的代碼如下。 (這個數字是R中使用製圖包製作。

到目前爲止,我已經使用[pos='1,1!',pin=true]嘗試,並在三個由三格遞增位置索引,但它並沒有改變結果的。

任何提示?

庫(製圖)

grViz(
    " 
digraph { 

    graph [overlap = true, fontsize = 10] 
    node [shape=circle] 
    Q11 [pos='1,1',pin=true] 
    Q21 [pos='2,1',pin=true] 
    Y1 [fillcolor=lightgray,style=filled,pos='3,1',pin=true] 

    Q11 -> Q21 
    Q11 -> Y1 
    Q21 -> Y1 

    node [shape = circle] 
    Q12 
    Q22 
    Y2 [fillcolor=lightgray,style=filled] 

    Q12 -> Q22 
    Q12 -> Y2 
    Q22 -> Y2 

    node [shape = circle] 
    Q13 
    Q23 
    Y3 [fillcolor=lightgray,style=filled] 

    Q13 -> Q23 
    Q13 -> Y3 
    Q23 -> Y3 


    {rank = same; Q11; Q12; Q13} 
    Q11 -> Q12 
    Q12 -> Q13 

    {rank = same; Q21; Q22; Q23} 
    Q21 -> Q22 
    Q22 -> Q23 
} 
    ", 
engine = 'neato') 
+0

你可以嘗試不同的內部和外部邊緣的權重,例如, 'Q11→Q21→Y1 [權重= 2]'和'Q11 - > Y1 [權重= 1]'。結果讓你更接近你想去的地方。但最終,手工佈置非常容易。 ;) – lukeA

回答

1

則應該通過添加constraint=false屬性禁用邊緣上的約束很少。

digraph { 
    graph [fontsize=10] 
    node [shape=circle] 
    Q21 
    Q22 
    Q23 
    Q12 
    Q11 
    Q13 

    Q21 -> Q22 [constraint=false] 
    Q22 -> Q23 [constraint=false] 

    Q11 -> Q21 
    Q11 -> Y1 [constraint=false] 
    Q21 -> Y1 

    Q12 -> Q22 
    Q12 -> Y2 [constraint=false] 
    Q22 -> Y2 


    Q13 -> Q23 
    Q13 -> Y3 [constraint=false] 
    Q23 -> Y3 

    {rank = same; Q11; Q12; Q13;} 
    Q11 -> Q12 [constraint=false] 
    Q12 -> Q13 [constraint=false] 

    {rank = same; Q21; Q22; Q23} 
    Y3 [fillcolor=lightgray,style=filled] 
    Y2 [fillcolor=lightgray,style=filled] 
    Y1 [fillcolor=lightgray,style=filled] 
} 

此代碼將在下面的圖形中生成。

FIxed graph

請了工作演示檢查http://graphviz.it/#/LXfbjEui

+0

你,先生,只是讓我的一天!謝謝! – Benjamin