我正在尝试在nodes标签下显示状态的属性。
目前是这样的:
________________________ ________________________
| | pause() | |
| |------------>| |
| | continue() | |
|________________________|<------------|________________________|
我有代码:
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()"});
我想或多或少地表现出来:
________________________ ________________________
| Ready | pause() | Paused |
| operation1, operation2 |------------>| operation1, operation2 |
| operation1, operation3 | continue() | operation1, operation3 |
|________________________|<------------|________________________|
由于很难找到使用graphviz的实现示例,我不知道如何在节点中添加值。转换之前有人知道我应该做些什么吗?
答案 0 :(得分:1)
我对graphviz4net一无所知,但只使用Graphviz的DOT language利用clusters来实现这一点很简单:
此图表的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可能有点压倒性,但它拥有你需要的一切。