有关Graphviz API的问题(Graphviz作为库) [英] Questions about Graphviz API (Graphviz as a library)

查看:141
本文介绍了有关Graphviz API的问题(Graphviz作为库)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Graphviz作为库(C ++).我需要Graphviz计算我的节点和相应边的坐标.我正在做自己的渲染(即不使用Graphviz的渲染器).我的节点是矩形,具有定义的宽度和高度(以像素为单位).

I'm using Graphviz as a library (C++). I need Graphviz to calculate coordinates for my nodes and respective edges. I'm doing rendering myself (i.e. not using Graphviz's renderers). My nodes are rectangles, with defined width and height (in pixels).

我使用 agopen 创建图形.然后,我使用 agnode 创建节点,并使用 agege 创建边缘.据我所知,那么应该使用 gvLayout 来计算坐标.

I create graph with agopen. Then I create nodes with agnode and edges with agedge. Then gvLayout should be used, as far as I know, for calculating the coordinates.

现在我需要知道:

  1. 在使用 gvLayout 之前如何指定节点的矩形的宽度和高度?

  1. How to specify nodes' rectangles' width and height, before using gvLayout?

gvLayout 之后,如何获取节点的计算坐标和边缘的样条曲线?

After gvLayout, how to get calculated coordinates for nodes and splines for edges?

如何从图中删除节点(和相应的边)或边( Agraph_t ),这完全可以做到吗?

How to delete node (and corresponding edges) or edges from graph (Agraph_t), can this be done at all?

当我使用 agnode agege 创建节点和边时,不需要释放/删除它们进行清理(完成后,图形)?还是 agclose 对此进行隐式处理?

When I create nodes and edges with agnode and agedge, don't I need to free/delete them for cleanup (when I'm done with graph)? Or does agclose handle this implicitly?

重要提示::我不想使用基于文本的界面(即以文本形式获取参数),我想访问提到的参数(节点的宽度和高度,边缘的样条线,节点...)直接作为数据变量.

Important: I don't want to use text-based interface (i.e. get parameters as text), I want to access mentioned parameters (width and height of node, splines of edge, coordinates of node...) directly as a data variables.

推荐答案

为先前的响应添加更多细节:

Adding a bit more detail to the previous response:

1)节点的宽度由多个属性确定:"width"属性指定最小宽度;节点中标签或图像的宽度;标签周围页边距的边距"属性;外围的数量;等等.如果您真的想固定宽度, 将宽度"属性设置为所需值,并将固定大小"设置为1.如上所述,您可以使用agset函数设置属性,该函数假定先前使用agnodeattr函数为节点声明了该属性.或者只是使用结合了操作的agsafeset.

1) The width of a node is determined by multiple properties: the "width" attribute specifies the minimum width; the width of the label or image in the node; the "margin" attribute for the margin around the label; the number of peripheries; etc. If you really want to fix the width, set the "width" attribute to the desired value and set "fixedsize" to 1. As noted above, you set attributes with the agset function, which assumes the attribute was previously declared using the agnodeattr function, for nodes. Or just use agsafeset, which combines the operations.

2)如果n是节点指针,则其位置作为(x,y)对存储在ND_coord(n)中.如果e是边缘指针,则值ED_spl(e)指向包含描述立方B样条曲线的结构数组的结构. (通常只有一个.)如果bz = ED_spl(e)-> list [0],则* bz包含用于点数,点的信息,以及有关边缘的头部是否有箭头的信息. /或尾巴.描述了这些值的含义 此处

2) If n is a node pointer, its position is stored as a (x,y) pair in ND_coord(n). If e is an edge pointer, the value ED_spl(e) points to a structure containing an array of structures describing cubic B-splines. (Usually, there is only one.) If bz = ED_spl(e)->list[0], then *bz has fields for the number of points, the points, and information as to whether the edge has arrows at the head and/or tail. This meaning of these values is described here

3)要从图g中删除节点n,请使用agdelete(g,n);

3) To delete node n from graph g, use agdelete(g, n);

4)在图形上调用agclose将自动释放所有节点和边.如果已调用gvLayout,则首先需要调用gvFreeLayout以释放为进行布局而分配的数据.

4) Calling agclose on the graph will automatically free all of the nodes and edges. If you have called gvLayout, you first need to call gvFreeLayout to free the data allocated for doing the layout.

您可能会发现文档很有帮助.

You may find this document helpful.

这篇关于有关Graphviz API的问题(Graphviz作为库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆