如何在Graphviz中优化布局以消除不必要的边交叉(交叉)?

4

我正在准备自动化数据库关系文档,使用的工具是graphviz。我的问题是输出图像中节点的位置不够优化,并且有许多不必要的边交叉。是否有方法对图进行优化,使结果具有最小的边交叉?

    digraph structs {
      node [shape=Mrecord];
      overlap="false";
      splines="true";
      layout=sfdp;
      rankdir=LR;

      ttype[label="::: ttype :::|<id>id|<table_name>table_name|<type_name>type_name|<synopsis>synopsis"];
      tevents[label="::: tevents :::|<id>id|<id_tcases>id_tcases|<id_ttype>id_ttype|<synopsis>synopsis|<expiredate>expiredate|<open>open"];
      toperationlog[label="::: toperationlog :::|<id>id|<executiondate>executiondate|<executiontime>executiontime|<query>query|<id_tusers>id_tusers"];
      tdocuments[label="::: tdocuments :::|<id>id|<id_tcases>id_tcases|<id_ttype>id_ttype|<path>path|<creationdate>creationdate"];
      tcustomers_cases[label="::: tcustomers_cases :::|<id_tcustomers>id_tcustomers|<id_tcases>id_tcases"];
      tcases[label="::: tcases :::|<id>id|<creationdate>creationdate|<incomingdate>incomingdate|<clousuredate>clousuredate|<synopsis>synopsis|<notes>notes|<id_ttype>id_ttype|<id_tusers>id_tusers"];
      tusers[label="::: tusers :::|<id>id|<username>username|<password>password|<firstname>firstname|<lastname>lastname|<role_id>role_id"];
      tcustomers[label="::: tcustomers :::|<id>id|<firstname>firstname|<lastname>lastname|<email>email|<phone>phone|<mobile>mobile|<address>address"];

      tevents:id_tcases -> tcases:id [arrowhead="none"];
      tevents:id_ttype -> ttype:id [arrowhead="none"];
      toperationlog:id_tusers -> tusers:id [arrowhead="none"];
      tdocuments:id_tcases -> tcases:id [arrowhead="none"];
      tdocuments:id_ttype -> ttype:id [arrowhead="none"];
      tcustomers_cases:id_tcustomers -> tcustomers:id [arrowhead="none"];
      tcustomers_cases:id_tcases -> tcases:id [arrowhead="none"];
      tcases:id_ttype -> ttype:id [arrowhead="none"];
      tcases:id_tusers -> tusers:id [arrowhead="none"];
    }
1个回答

3

remincross 设为 true 将会导致交叉最小化运行第二次,从而通过减少边的交叉数量来改善图形的外观。


有没有一种算法可以做到这个? - jokoon
这是值得记录的,这现在是Graphviz上的默认行为。链接 - Alex

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接