gpt4 book ai didi

graphviz - 混合垂直和水平布局(用于水平布局的类图)

转载 作者:行者123 更新时间:2023-12-02 03:23:41 31 4
gpt4 key购买 nike

我正在尝试在 GraphViz 中显示类图。我希望它主要是水平布局的——但是我遇到了一个问题,因为它也水平地分离了每个类的三个部分(即类名、属性和方法)也被水平显示。我已为每个单独的节点尝试使用 rankdir = LR 的子图,但它不起作用。

这是我的代码:

digraph hierarchy {
node[shape=record,style=filled,fillcolor=gray95]
edge[dir=back, arrowtail=empty]
graph[size="20,10"]
rankdir=LR

1[label = "{Hazards|+ ID\n + Description\n + RiskLevel|+f Topics}" ]
2[label = "{Faults|+ ID\n + Fault\n + Likelihood\n + Impact\n + Mitigation|+f Topics}"]
3[label = "{User Requirements|+ ID\n + Requirement\n + Status\n + Priority\n + Contributors|+f NFR Types\n+fTopics\n +f Find-the-expert\n+f Volatility}"]
4[label = "{Acceptance Tests|+ TestID\n + Script\n +CurrentStatus|+f Coverage}"]
5[label = "{Acceptance Test Log|+ TestID\n +DateRun\n + Relevance}"]
6[label = "{Regulatory Codes|+ ID\n + Regulation\n + Likelihood\n + Impact\n + Mitigation|+f Topics}"]
7[label = "{State Transition Diagram|+ ID\n + States\n + Transitions\n + Model}"]
8[label = "{System Requirements|+ ID\n + Description\n +Status\n + Priority|+f Topics}"]
9[label = "{Work Item|+ ID\n +Description\n + AssignedTo\n + DateCompleted\n + Comments|+f ProjectVelocity}"]
10[label = "{Bug Tracker|+ ID\n + Title\n +ReportedOn\n + FixedOn\n + Symptoms\n + State\n + Effort|+f Find-the-expert}"]
11[label = "{Source Code|+ ClassName\n +Code\n + CreatedBy\n + CreatedOn\n + LastModifiedBy\n + LastModifiedOn|+f Fault Likelihood\n + f Topics}"]
12[label = "{Unit Tests|+ TestID\n + Script\n +CurrentStatus|+f Coverage}"]
13[label = "{Unit Test Log|+ TestID\n + DateRun\n + ByWhom\n +Status\n + ActionItems}"]
14[label = "{Components|+ ID\n + Name|+f Fault Likelihood}"]

1->2
2->3
3->4
4->5
2->8
3->8
8->6
8->7
8->9
10->9
8->11
14->11
11->12
12->13
11->9
}

不幸的是,我不被允许发布图片,因为我没有 StackOverflow 的声誉。但是,您可以通过将 rankdir =LR 替换为 rankdir=TB 来查看垂直解决方案。

有谁知道如何组合这两种布局,使类保持堆叠,即类名在属性之上,在函数之上等等,但整体布局是 LR?

如果可以在 GraphVis 中直接指定它,我宁愿不使用 UMLGraph.lib。

非常感谢简

最佳答案

因此答案是:

digraph hierarchy {
node[shape=record,style=filled,fillcolor=gray95]
edge[dir=back, arrowtail=empty]
graph[size="15,20"]
rankdir=LR

1[label = "Hazards|+ ID\n + Description\n + RiskLevel\n+f Topics"]
2[label = "Faults|+ ID\n + Fault\n + Likelihood\n + Impact\n + Mitigation|+f Topics"]
3[label = "User Requirements|+ ID\n + Requirement\n + Status\n + Priority\n + Contributors|+f NFR Types\n+fTopics\n +f Find-the-expert\n+f Volatility"]
4[label = "Acceptance Tests|+ TestID\n + Script\n +CurrentStatus|+f Coverage"]
5[label = "Acceptance Test Log|+ TestID\n +DateRun\n + Relevance"]
6[label = "Regulatory Codes|+ ID\n + Regulation\n + Likelihood\n + Impact\n + Mitigation|+f Topics"]
7[label = "State Transition Diagram|+ ID\n + States\n + Transitions\n + Model"]
8[label = "System Requirements|+ ID\n + Description\n +Status\n + Priority|+f Topics"]
9[label = "Work Item|+ ID\n +Description\n + AssignedTo\n + DateCompleted\n + Comments|+f ProjectVelocity"]
10[label = "Bug Tracker|+ ID\n + Title\n +ReportedOn\n + FixedOn\n + Symptoms\n + State\n + Effort|+f Find-the-expert"]
11[label = "Source Code|+ ClassName\n +Code\n + CreatedBy\n + CreatedOn\n + LastModifiedBy\n + LastModifiedOn|+f Fault Likelihood\n + f Topics"]
12[label = "Unit Tests|+ TestID\n + Script\n +CurrentStatus|+f Coverage"]
13[label = "Unit Test Log|+ TestID\n + DateRun\n + ByWhom\n +Status\n + ActionItems"]
14[label = "Components|+ ID\n + Name|+f Fault Likelihood"]

1->2
2->3
3->4
4->5
2->8
3->8
8->6
8->7
8->9
10->9
8->11
14->11
11->12
12->13
11->9

关于graphviz - 混合垂直和水平布局(用于水平布局的类图),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31543131/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com