微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

graphviz中节点的顺序

如何解决graphviz中节点的顺序

我正在处理这个图表:

import 'dart:async';
import 'dart:io';

import 'package:golden_toolkit/golden_toolkit.dart';

Future<void> testExecutable(FutureOr<void> Function() testMain) async {
  return GoldenToolkit.runWithConfiguration(
    () async {
      await loadAppFonts();
      await testMain();
    },config: GoldenToolkitConfiguration(
      // Currently,goldens are not generated/validated in CI for this repo.     We have settled on the goldens for this package
      // being captured/validated by developers running on MacOSX. We may revisit this in the future if there is a reason to invest
      // in more sophistication
      skipGoldenAssertion: () => !Platform.isMacOS,),);
}

This is my current graph.

我想尽量减少交叉。 我的首选布局是 A1、S1 和 J1 按从左到右的顺序位于同一等级。 但是我不知道如何做到这一点。

有人可以帮忙吗?提前致谢。

解决方法

许多“明显”的解决方案不起作用(排序、重量、隐形边缘)。将 A1、J1 和 S1 放在一个集群中就行了:

digraph "example.gsn.yaml" {
  ## Elements
  "G1" [shape="box",label=<<B>G1</B><BR align="left"/>Goal 1>];
  "G2" [shape="box",label=<<B>G2</B><BR align="left"/>Goal 2>];
  "G4" [shape="box",label=<<B>G4</B><BR align="left"/>Goal 4>];
  "G3" [shape="box",label=<<B>G3</B><BR align="left"/>Goal 3>];
  "C1" [shape="box",style="rounded",label=<<B>C1</B><BR align="left"/>Context 1>];
  "S1" [shape="parallelogram",label=<<B>S1</B><BR align="left"/>Strategy 1>];
  "A1" [shape="oval",label=<<B>A1</B><BR align="left"/>Argument 1>];
  "A1":e -> "A1":e [headlabel=< <B>A</B> >,labeldistance=2.5,penwidth=0,arrowhead=none];
  "Sn1" [shape="circle",label=<<B>Sn1</B><BR align="left"/>Solution 1>];
  "Sn2" [shape="circle",label=<<B>Sn2</B><BR align="left"/>Solution 2>];
  "J1" [shape="oval",label=<<B>J1</B><BR align="left"/>Justification 1>];
  "J1":e -> "J1":e [headlabel=< <B>J</B> >,arrowhead=none];

  subgraph clusterg1{
    graph[peripheries=0]  // no box around the cluster
    {rank = same; node[group=g1] edge[style=invis]  "A1" -> "S1" ->  "J1"}
  }

  ## Relations
  "G1" -> "G2";
  "G1" -> "G3";
  "G1" -> "G4";
  "G2" -> "S1";
  "G4" -> "Sn2";
  "G3" -> "Sn1";
  "G3" -> "C1" [arrowhead=empty];
  {rank = same; "G3"; "C1"; }
  "S1" -> "Sn1";
  "S1" -> "J1" [arrowhead=empty];
  "A1" -> "S1" [arrowhead=empty dir=back];
}

enter image description here

附言A1->S1 箭头是否正确?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。