2013-10-11 4 views
0

노드 레이블 아래에서 상태 속성을 표시하려고합니다.graphviz의 오브젝트 속성

그것은 다음과 같이 현재의 : 나는 더 많거나 적은 같은 그것을 보여주고 싶은

 Graph = new Graph<State>(); 
     var a = new State() 
     { 
      Status = "Ready", 
      AllowedPurchaserOperations = "operation1, operation2", 
      AllowedSupplierOperations = "operarion1, operation 3" 
     }; 
     var b = new State() 
     { 
      Status = "Paused", 
      AllowedPurchaserOperations = "operation1, operation2", 
      AllowedSupplierOperations = "operarion1, operation 3" 
     }; 

     Graph.AddVertex(a); 
     Graph.AddVertex(b); 

     Graph.AddEdge(new Edge<State>(a, b) {Label = "pause()"}); 
     Graph.AddEdge(new Edge<State>(b, a) {Label = "continue()"}); 

:

________________________    ________________________ 
|      | pause() |      | 
|      |------------>|      | 
|      | continue() |      | 
|________________________|<------------|________________________| 

나는 코드가

________________________    ________________________ 
|   Ready   | pause() |   Paused   | 
| operation1, operation2 |------------>| operation1, operation2 | 
| operation1, operation3 | continue() | operation1, operation3 | 
|________________________|<------------|________________________| 

는 어렵다으로 graphviz를 사용하여 구현 예제를 찾으십시오. 노드에 값을 추가하는 방법을 모르겠습니다. 누군가 그것을 변환하기 전에해야 할 일을 알고 있습니까?

+0

QuickGraph를 사용하고 있습니까? – marapet

+0

@marapet graphviz4net을 사용 중입니다. – Th3B0Y

+0

불행히도 질문에 graphviz4net 태그가 지정되지 않았지만, 늦어도 좋을만큼 좋습니다. WPF에서 그래프 요소를 사용자 정의하는 방법에 대한 간단한 기사 : http://graphviz4net.codeplex.com/wikipage?title=Customization%20of%20various%20graph%20elements&referringTitle=Documentation – Steves

답변

1

나는 graphviz4net에 대해 아무것도 몰라하지만이 graphviz를의 DOT languageclusters을 활용하여 단지 달성하기 위해 매우 간단합니다 :

다음

graph

이 그래프에 대한 DOT 파일입니다 같이

digraph g{ 

    // Set the graph direction from left to right 
    // otherwise the boxes will be above eachother 
    // with the arrows pointing up and down 
    rankdir="LR" 

    // hide the border of the nodes in the cluster supgraph 
    node [shape = "none"] 

    // make the lines dashed, remove if you want solid lines 
    edge [style = "dashed"] 

    subgraph cluster_ready { 
     label = "Ready" 

     ready_op_1_2 [label="operation1, operation2"] 
     ready_op_1_3 [label="operation1, operation3"] 
    } 

    subgraph cluster_paused { 
     label = "Paused" 

     paused_op_1_2 [label="operation1, operation2"] 
     paused_op_1_3 [label="operation1, operation3"] 
    } 

    ready_op_1_2 -> paused_op_1_2 [label="pause()"] 
    paused_op_1_3 -> ready_op_1_3 [label="continue()"] 
} 

다양한 요소의 글꼴, 색상 및 스타일을 변경하여 모양을 상당히 쉽게 조정할 수 있습니다. 그것으로 놀기 위해서 나는 어떤 속성 (그리고 그것의 설정)이 무엇을하는지에 대해 빠른 느낌을 얻기 위해 GraphViz Workspace을 사용할 것을 제안 할 것이다. attribute manual은 약간 압도 될 수 있지만 필요한 모든 것을 갖추고 있습니다.

+0

답변이 많이 명확 해졌습니다. 감사합니다. C#에서 node [shape = "none"]을 어떻게 설정할 수 있는지 알고 있습니까? graphviz4net을 사용하고 있습니다. – Th3B0Y

+0

도와 주셔서 감사합니다. 불행히도 graphviz4net에 대한 경험이 없습니다. 나는 프로젝트를 살펴 봤지만 나에게 Graphviz를 감싸는 지나치게 복잡한 방법처럼 보인다. 프로젝트가 아주 희박하게 문서화되어 있기 때문에 소스 코드 이외의 다른 점을 지적하지는 않을 것입니다 :-(노드의 색상을 변경하는 방법을 알고 있다면 배경과 같은 색으로 설정할 수 있습니까? [AntlrParserAdapter 클래스] (http://graphviz4net.codeplex.com/wikipage?title=DOT%20parsing%20with%20Graphviz4Net)에 DOT 구문을 입력하는 것이 최선의 방법이라고 생각하십시오. – Potherca

관련 문제