可视化由python中编码的边连接的节点序列.
寻找一个python库来可视化这样的图形数据.
用python或python绑定编写的库都可以
(我知道Visustin,但寻找替代方案)
我正在构建一个epsilon NFA,以使用规范构造识别正则表达式.我正在使用子图来对正则表达式的各个部分进行分组.由于dot决定移动节点的顺序,*运算符给了我特别的麻烦.我已经尝试添加边缘权重以强制特定边缘变短以保持边缘的顺序,但这似乎不起作用.
我想要做的是强制子图中的节点按特定顺序放置,以便输出图可以识别为特定类型的(众所周知的)构造.在下面的示例中,我希望边缘3,4,5和6按此顺序放置,但是点将它们按6,3,4,5的顺序放置.任何指针都会被欣赏.
请注意,当前权重参数与完全没有权重参数没有任何区别.
我有以下内容
digraph G {
rankdir = LR;
node [shape = none];
0 [label = "start"];
node [shape = circle];
1 [label = "q1"];
2 [label = "q2"];
3 [label = "q3"];
4 [label = "q4"];
5 [label = "q5"];
node [shape = doublecircle];
6 [label = "q6"];
subgraph re1 {
rank = same;
edge[label = "0"];
1 -> 2;
};
subgraph re2 {
rank = same;
edge[label = "ε"];
3 -> 4 [weight = 10];
edge[label …Run Code Online (Sandbox Code Playgroud) 我正在努力学习一些Python图形可视化.我发现了一些博客文章做了一些 我想尝试的事情.不幸的是我没有走得太远,遇到这个错误:AttributeError: 'module' object has no attribute 'graphviz_layout'
在我的系统上重现错误的最简单的代码片段是这样的,
In [1]: import networkx as nx
In [2]: G=nx.complete_graph(5)
In [3]: nx.draw_graphviz(G)
------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-481ad1c1771c> in <module>()
----> 1 nx.draw_graphviz(G)
/usr/lib/python2.7/site-packages/networkx/drawing/nx_pylab.pyc in draw_graphviz(G, prog, **kwargs)
982 See networkx.draw_networkx() for a description of optional keywords.
983 """
--> 984 pos = nx.drawing.graphviz_layout(G, prog)
985 draw(G, pos, **kwargs)
986
AttributeError: 'module' object has no attribute 'graphviz_layout'
Run Code Online (Sandbox Code Playgroud)
我想强制点只显示节点之间的垂直或水平边缘.
我发现了一个类似的请求,使用Dot/GraphViz发布了Family树布局,但我没有处理树,所以我希望有一个解决方案,而不插入额外的节点...
如果我构建以下图表:
digraph G {
splines=ortho
A [ shape=box ]
B [ shape=box ]
C [ shape=box ]
D [ shape=box ]
A -> B
A -> C
B -> D
C -> D
}
我得到的是这个:

但我想要一个像这样的图表:

我怎样才能得到这样的渲染?
编辑:"splines"属性似乎没有按预期工作......有没有我做错了?
我使用doxygen + graphviz来记录我的代码.graphviz在生成图像方面做得很好.
有没有办法更改graphviz的默认fontsize?默认值为14,但我想使用12代替.
更改单个元素(如节点,子图,边缘等)的字体大小真是太痛苦了.
更新:
这里参考的是我在doxygen中使用的代码,(文本字段已经重命名,当然)
@dot
strict digraph {
node [shape = box, fontsize = 12];
subgraph cluster_main {
fontsize = 12;
shape = box;
label = "main";
subgraph cluster_main_common {
fontsize = 12;
shape = box;
label = "common";
subgraph cluster_main_common_source {
fontsize = 12;
shape = box;
label = "source"
subgraph cluster_file1 {
fontsize = 12;
shape = box;
label = "file1.c";
gSystem [label = "var1" URL = "\ref var1"];
}
subgraph cluster_file2 {
fontsize = …Run Code Online (Sandbox Code Playgroud) 我正在尝试打印有向图,并且我不断更改各种节点属性,例如颜色和形状.有没有办法使用一次定义并用于多个节点的变量?理想情况下,我喜欢这样的事情:
digraph g {
building_color = "red"
land_color = "green"
farm [ fillcolor=land_color]
barn [ fillcolor=building_color]
house [ fillcolor=building_color]
}
Run Code Online (Sandbox Code Playgroud)
所以我可以改变建筑颜色一次,而不必去每个节点.这可能吗?
我有一个这样的图形文件:
digraph {
"Step1" -> "Step2" -> "Step3";
subgraph step2detail {
"Step2" -> "note1";
"Step2" -> "note2";
"Step2" -> "note3";
"Step2" -> "note4";
rankdir=TB
}
}
Run Code Online (Sandbox Code Playgroud)
我希望子图step2detail挂在'Step2'的右边.
现在它看起来像这样:

我希望Step1,Step2和Step3全部垂直位于彼此之下且位于1列中.
我想用以下代码对一些节点进行分组
digraph dataflow {
subgraph pipeline {
relations;
synonyms;
articles;
}
subgraph lucene {
index;
search;
}
training_data - > index;
relations - > search;
synonyms - > index;
articles - > index;
training_data - > evaluation;
}
Run Code Online (Sandbox Code Playgroud)
但dot并不关心子图:

我尝试过使用xlp并且也遵循这个graphviz线程(http://www.graphviz.org/content/how-use-xlp-attribute-positioning-external-labels-xlabel),但两者都没有实际工作.
这是我的点代码:
digraph {
forcelabels=true;
rankdir=LR;
graph[ranksep=1,nodesep=.5];
node[shape=box];
"start" [xlabel="start",xlp="0,0",shape=doublecircle,label=" "];
"requested"->"fault";
"requested"->"progress";
"start"->"requested";
"progress"->"fault";
"progress"->"progress";
"progress"->"complete";
"fault" [xlabel="fault",shape=doublecircle,label=" "];
"complete" [xlabel="complete",shape=doublecircle,label=" "];
}
Run Code Online (Sandbox Code Playgroud)
这就是它的样子:

理想情况下,start,fault和complete将直接位于节点之下,但我似乎无法正确定位xlabels.