如何使用 GraphViz 生成多个级别(PHP 的 Image_Graphviz 接口)
我正在尝试使用 PEAR 的 Image_GraphViz 生成下图。但是,它仅显示顶级节点(带有文本“0”)和直接位于顶级节点下方的子节点“1”、“2”、“3”和“4”。我错过了什么吗?
这是代码:
$gv = new Image_GraphViz(true);
$gv->addEdge(array('1', '2'));
$gv->addEdge(array('2', '3'));
$gv->addEdge(array('2', '4'));
$gv->addEdge(array('3', '5'));
$gv->addEdge(array('3', '6'));
$gv->addEdge(array('3', '7'));
$gv->addEdge(array('4', '5'));
echo $gv->fetch('svg');
我尝试了以下操作,但这显然是错误的:)。
$gv->addEdge(array('1', '2'));
$gv->addEdge(array('1', '2', '3'));
$gv->addEdge(array('1', '2', '4'));
$gv->addEdge(array('1', '2', '3', '5'));
$gv->addEdge(array('1', '2', '3', '6'));
$gv->addEdge(array('1', '2', '3', '7'));
$gv->addEdge(array('1', '2', '4', '5'));
我知道有两种方法可以达到 5
。通过 (1, 2, 3, 5)
和/或 (1, 2, 4, 5)
。
图像应该只显示指向 5
的两行。我很困惑,有什么建议吗?
i'm trying to generate the following diagram using Image_GraphViz for PEAR. However It only shows a top-level node (with the text "0") and childnodes "1", "2", "3" and "4" directly under the top-node. Am I missing something?
This is the code:
$gv = new Image_GraphViz(true);
$gv->addEdge(array('1', '2'));
$gv->addEdge(array('2', '3'));
$gv->addEdge(array('2', '4'));
$gv->addEdge(array('3', '5'));
$gv->addEdge(array('3', '6'));
$gv->addEdge(array('3', '7'));
$gv->addEdge(array('4', '5'));
echo $gv->fetch('svg');
I tried the following, but this is obviously wrong :).
$gv->addEdge(array('1', '2'));
$gv->addEdge(array('1', '2', '3'));
$gv->addEdge(array('1', '2', '4'));
$gv->addEdge(array('1', '2', '3', '5'));
$gv->addEdge(array('1', '2', '3', '6'));
$gv->addEdge(array('1', '2', '3', '7'));
$gv->addEdge(array('1', '2', '4', '5'));
I understand there are two ways to get to 5
. Through (1, 2, 3, 5)
and/or (1, 2, 4, 5)
.
The image should just show two lines going to 5
. I'm very confused, any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从文档来看,您似乎需要关联数组。你可以试试这个吗?
From the documentation it seems you need associative arrays. Can you try this instead?