'IT/GraphViz'에 해당되는 글 3건

  1. 2013.12.06 DOT을 이용한 Graph그리기
  2. 2013.12.06 GraphViz의 Node종류
  3. 2013.12.06 GraphViz에 관하여
posted by dalnimbest 2013. 12. 6. 15:09

1. 첫번째

digraph name1 {

    //그래프가 나타내는 순서가 Top -> Bottom이다. LR은 Left -> Right임

    rankdir = TB;  //default


    //이하의 모든 노드는 Polygon에 blue칼라를 가진다.

    node [shape = polygon, color = blue]

    

    //node1은 node의 속성을 가지고, 속의 색을 blue로 채우고(fill), 테두리를 둥글게 만든다(rounded).

    node1 [style = "filled, rounded"]


    //node2는 record타입이며, 속의 색을 채우는데 채우는 색은 빨간색이다. 테두리색은 따로 지정하지 않았으므로 위에서 선언된 blue칼라를 가진다. 

    //record에 들어가는 칸은 총 3칸이로 첫번째 칸은 1이고 두번째 칸은 2와 3번이 세로로 각각들어가며 마지막탄은 4번이 들어간다.

    //<f2>는 node2에서 연결될때 "4"해당되는 ID이다.

    node2 [shape = record, style = filled, fillcolor = red, label = "1|{2|3}|<f2>4"]


    //순서대로 화살표를 그린다.

    node0 -> node1 -> node2;


    //node2의 f2 ("4"가 있는 부분)에서 node1으로 화살표를 그린다.

    node2:f2 -> node1;

    


    //이 이하부터는 record타입이다. style은 dashed가 적용된다. 색상은 재 지정이 없었으므로 위의 Node에서 지정한 Blue가 적용된다.

    node [shape=record, style = "dashed"];


    //record형 변수(?) struct0을 하나 선언하고 값은 A,B,C,D를 넣어준다.

    struct0 [label= "A | B | C | <f1>D" ];


    //struct1은 3개의 값을 가지는데 각각에 대해서 ID를 부여했다.

    //첫번째는 f0이라는 ID이며

    //두번째는 mid와 dle사이를 띄는데, &#92;가 뭘의미하는지 모르겠음.

    struct1 [label="<f0> left|<f1> mid&#92; dle|<f2> right"];


    //이 이후의 node style은 테두리가 둥글고, 속을 채우며(fillcolor를 따로 지정하지 않으면 color의 값이 테두리에도 사용되고 속을 채우는 색으로도 사용된다, 그래서 내부 선의 색상이 동일해서 안보인다.), 점선이다

    //색상은 red로 바꾸었다. 

    node [style = "rounded, filled, dotted", color = red]

    //  두개의 값을 가짐 (one, two)

    struct2 [label="<f0> one|<f1> two"];


    //이 이후의 node style은 속을 채우는것이다. dotted가 명기 되지 않으면, solid가 default로 사용된다.

    //테두리는 노란색, 채우는 색은 빨간색이다.

    node [style = "filled", color = yellow, fillcolor = red];

    //첫벗째는 hello다음에 개행문자(&#92;n)를 넣어준다.

    //두번째는 {}로 감싸므로 위->아래로 넣는데, b를 맨위로, 그밑에는 다시 {}로 둘러싸므로 c, d, e 순으로 넣는데, d앞에는 "here"라는 ID를 하나 넣어준다. 

    struct3 [label="hello&#92;nworld |{ b |{c|<here> d|e}| f}| g | h"];


    //node1에서 struct의 f1이라는 ID로 화살표를 그린다.

    node1 -> struct1:f1;


    //struct0의 f1 ID에서 struct1의 f0라는 ID로 화살표를 그린다.

    struct0:f1 -> struct1:f0;

    struct1:f1 -> struct2:f0;

    struct1:f2 -> struct3:here;

   

}








2. 두번째

digraph name2 {

    // graph의 크기를 설정하는데 작게는 되는게 크게는 되지 않네...

    size="10,5";


    //노드의 shape, style, font 설정

    node [shape = diamond, color = blue, fontname="Tahoma", fontsize="12"];


    //이하 edge의 색은 blue이다.

    edge [color = blue]


    //A의 속성을 따로 정의합니다. 

    A [shape=polygon, label = "This\nis\nA", peripheries = 2];     


    // A의 Shape은 polygon이지만, 나머지의 shape은 위에서 정한 diamond이다

    // 여기서 사용된 화살표 style는 dotted이며, 빨간색이다. edge에 "test"라는 글자를 뿌려준다. (이는 여기서만 사용되는 style이다)

    A -> B [style = "dotted", label = "test",color = red];    


    //선을 bold로 하고 색상은 green으로 한다.

    B -> C [style = bold, color = green];

    

    //weight는 B의 위치 조절이다, 다른 font를 적용한다.

    B -> D [weight=0, label = "dalnim" ,fontname="arial", fontsize = "9"];


    // B->E;

    // B->F;  이 두개를 한번에 표현하는것이다.

    B -> {E;F} [style = "dashed"];

}






3. 세번째

digraph G {


    node [shape = invtriangle];


    d [shape=lpromoter];

    e [shape=polygon, skew=.5];

    e1 [shape=polygon, skew=.8];

    f [shape=box3d];

    g [shape=underline];

    h [shape=none, label = "shape_none"];

    i [shape=component];

    j [shape=point];

    k [shape=star];

    l [shape=plaintext, label = "shape_plaintext"];

    m [color = lightgray, peripheries=2, style=filled];

    //

    e [shape=polygon,sides=4,distortion=.6];

    a ->b ->c -> { a1; a2} ;

    b ->d;

    d -> e -> e1 -> f -> g -> m;

    h -> i -> j -> k -> l;

}







UML처럼 사용하는건 아래를 참조하자.

http://www.ffnn.nl/pages/articles/media/uml-diagrams-using-graphviz-dot.php



'IT > GraphViz' 카테고리의 다른 글

GraphViz의 Node종류  (0) 2013.12.06
GraphViz에 관하여  (0) 2013.12.06
posted by dalnimbest 2013. 12. 6. 10:24

http://www.graphviz.org/content/attrs#karrowType


Graph는 Node와 Edge로 구성되어 있는데 


Node는 다음과 같은 3가지의 타입이 있다.


1. Polygon-based Nodes


box   circle  star  right arrow 


Record-based Nodes





'IT > GraphViz' 카테고리의 다른 글

DOT을 이용한 Graph그리기  (0) 2013.12.06
GraphViz에 관하여  (0) 2013.12.06
posted by dalnimbest 2013. 12. 6. 09:19


GraphViz는 AT&T에서 만든 Graph Visualization Software로 오픈소스이고 CPL 라이센스를 따른다. 아래와 같은 형태의 Graph를 만들수 있다.

    


홈페이지는 http://www.graphviz.org/Home.php 이다.


Graph 를 그리기 위해서 DOT 스크립트를 사용한다.


아래는 방향성이 있는 그래프를 그리는 기본 문법 형식이다.

digraph name {

    a -> b->c;

    b->d;

}


그러면 아래와 같은 형태의 Graph가 표시된다.



아래는 방향성이 없는 그래프를 그리는 기본 문법 형식이다. 

graph name {

    a -- b--c;

    b -- d;

}






Graph를 파일형태로 저장하기 위해서는 Output File Type과 Output File Name을 지정해줘야 한다.


아래에서는 PNG 포맷으로 바탕화면 밑에 1.png라는 이름으로 저장했다.





Layout Engine에 따라서 Graph의 모양이 여러가지로 달라진다.


dot - 계층적, 방향성이 있는 그래프를 그릴때 default로 사용한다. 

      - "hierarchical" or layered drawings of directed graphs. This is the default tool to use if edges have directionality.

neato - "spring model''을 그릴때 사용한다. 그릴 그래프가 너무 크지 않을때.(약 100개 정도의 노드)  

          - "spring model' layouts.  This is the default tool to use if the graph is not too large (about 100 nodes) and you don't know anything else about it. Neato attempts to minimize a global energy function, which is equivalent to statistical multi-dimensional scaling.

fdp - neato와 비슷한데 차이점은?

      -  "spring model'' layouts similar to those of neato, but does this by reducing forces rather than working with energy.

sfdp - multiscale version of fdp for the layout of large graphs.

twopi - radial layouts, after Graham Wills 97. Nodes are placed on concentric circles depending their distance from a given root node.

circo - circular layout, after Six and Tollis 99, Kauffman and Wiese 02. This is suitable for certain diagrams of multiple cyclic structures, such as certain telecommunications networks.

'IT > GraphViz' 카테고리의 다른 글

DOT을 이용한 Graph그리기  (0) 2013.12.06
GraphViz의 Node종류  (0) 2013.12.06