2015-01-14 13 views
3

다음과 같은 gv 코드가 있습니다. 생성 된 그래프에 머리말과 꼬리말로 텍스트 나 이미지를 추가하고 싶습니다.graphviz에 머리글과 바닥 글 추가

digraph testdot { 

label=" Name: MY NAME \l Address: Address ...... \l "; 

START_NODE [ shape=ellipse label= "START" ]; 
ERROR_NODE0 [ shape=box label= "Error0" ]; 
ERROR_NODE1 [ shape=box label= "Error1" ]; 
ERROR_NODE2 [ shape=box label= "Error2" ]; 
ERROR_NODE3 [ shape=box label= "Error3" ]; 

Statement_0 [ shape=diamond label= "if foo " ]; 
Statement_1 [ shape=diamond label= "if foo1" ]; 
Statement_2 [ shape=diamond label= "if foo2" ]; 
Statement_3 [ shape=diamond label= "if foo3" ]; 

START_NODE -> Statement_0; 
Statement_0 -> Statement_1 [label= "No" ]; 
Statement_0 -> ERROR_NODE0 [label= "Yes" ]; 
Statement_1 -> Statement_2 [label= "No" ]; 
Statement_1 -> ERROR_NODE1 [label= "Yes" ]; 
Statement_2 -> Statement_3 [label= "No" ]; 
Statement_2 -> ERROR_NODE2 [label= "Yes" ]; 
Statement_3 -> Statement_4 [label= "No" ]; 
Statement_3 -> ERROR_NODE3 [label= "Yes" ]; 
} 

아래는이 작업을 위해 '점'을 사용하는 경우 내가

Below is an example of how I want the output as

답변

3

로 출력을 원하는 방법의 예입니다, 점 그래프의 요소의 위치를 ​​제어 할 수 없습니다. 즉, 그래프의 구조를 아는 경우 하위 그래프, 순위 및 숨겨진 모서리를 사용하여 몇 가지 트릭을 수행 할 수 있습니다.

이 그래프에 대한 가능한 해결책이 될 것입니다 :

digraph testdot { 

subgraph clusterHeader { 
    margin=0 
    style="invis" 
    HEADER [shape="box" label="This is the header"]; 
} 

subgraph clusterMain { 
    margin=0 
    style="invis" 
    START_NODE [ shape=ellipse label= "START" ]; 
    ERROR_NODE0 [ shape=box label= "Error0" ]; 
    ERROR_NODE1 [ shape=box label= "Error1" ]; 
    ERROR_NODE2 [ shape=box label= "Error2" ]; 
    ERROR_NODE3 [ shape=box label= "Error3" ]; 

    Statement_0 [ shape=diamond label= "if foo " ]; 
    Statement_1 [ shape=diamond label= "if foo1" ]; 
    Statement_2 [ shape=diamond label= "if foo2" ]; 
    Statement_3 [ shape=diamond label= "if foo3" ]; 

    START_NODE -> Statement_0; 
    Statement_0 -> Statement_1 [label= "No" ]; 
    Statement_0 -> ERROR_NODE0 [label= "Yes" ]; 
    Statement_1 -> Statement_2 [label= "No" ]; 
    Statement_1 -> ERROR_NODE1 [label= "Yes" ]; 
    Statement_2 -> Statement_3 [label= "No" ]; 
    Statement_2 -> ERROR_NODE2 [label= "Yes" ]; 
    Statement_3 -> Statement_4 [label= "No" ]; 
    Statement_3 -> ERROR_NODE3 [label= "Yes" ]; 
} 

subgraph clusterFooter { 
    margin=0 
    style="invis" 
    LABEL_1 [shape="none" margin=0 label="NAME: My name\lAddress: 23 XYZ road"]; 
    {rank="sink"; FOOTER [shape="box" label="Footer text goes here"];} 
} 

// Connecting the subgraps in order. Try to connect a bottom node of your main 
// clusterMain to LABEL_1 
HEADER->START_NODE [style=invis]; 
ERROR_NODE3->LABEL_1 [style=invis weight=0]; 
LABEL_1->FOOTER [style=invis weight=0]; 

} 
+2

추가로 사용하면 노드 레이블로 HTML 테이블을 사용할 수 있습니다, [HTML 같은 레이블] (http://www.graphviz.org/doc/ 참조 info/shapes.html # html) – stefan

관련 문제