get_hierarchy_control_points return values

Hi again,
I'm writing a small package that builds on graph-tool, but not on its graphics capabilities (also because I have to represent other things rather than the graph itself). Still I could use some of the functions "under the hood" for my purposes. I have a question about gt.draw.get_hierarchy_control_points(): the function returns the Bézier spline control points for edges in a given graph, but I'm having difficulties in understanding how this information is encoded. For a single edge in graph, I have dozens of values as control points (half dozens + 2), hence I suspect all splines going from node A to the root of a hierarchy and back to node B are encoded there, and control points should be taken 6 by 6 (3x2 by 3x2 coordinates?). How (x,y) for control points are encoded then: (x, x, x, y, y, y) or (x, y, x, y, x, y)? What are the 2 additiona values I have for each vector? Also, are values absolute or relative to one node in particular (A, B or root...)?
Thanks

d

Hi,
I have the same question, except that in my case I do not have always the
same number of points.... Did you find any information on that?

A.

Hi,
I would like to know also how the info are formatted... In my case the
length of the property is not the same across the edges...
Thanks,
A.

The documentation of graph_draw() for "edge_control_points" says:

Control points of a Bézier spline used to draw the edge. Each spline
segment requires 6 values corresponding to the (x,y) coordinates of the
two intermediary control points and the final point.

Bézier splines are defined as such:

https://en.wikipedia.org/wiki/Bézier_curve

Best,
Tiago

Hi Tiago,
Sure the documentation states that there should be 6 points, but in my case
the length of the map is variable, so I think that either the documentation
is outdated, or the format of the map is not correct. Sometimes I have a
length of 40 for the vector, sometimes 50 or so.
Thanks,
A.

The documentation clearly states that it's 6 values *per spline
segment*, of which there can be an arbitrary amount.

Ok, that seems right, but still, there is something that I do not understand.
I followed the piece of code of the documentation of
graph_tool.draw.get_hierarchy_control_points
<https://graph-tool.skewed.de/static/doc/draw.html?highlight=get_hierarchy_control_points#graph_tool.draw.get_hierarchy_control_points&gt;
, and when I print the length of the map /cts/ I get value that are not
divisible by 6 (86,50,38,62...), so there is one more point coming out of
the function /get_hierarchy_control_points/ and used in /graph_draw/.
But thanks for the clarification of the several spline segments. I didn't
get that.

A

Yes, this is because of a boundary condition: The last point does not
need to be specified, just as the first one. If it's given, it's
ignored. The function get_hierarchy_control_points generates the final
point because it's slightly easier in the code.

Ok, but then I should be able to find the edge's target position in the
points generated by the the function get_hierarchy_control_points right? If
it is not the last two components of the vector (boundary condition?) it
should at the position [-4:-3]?
If I understand correctly what you said, from the function
get_hierarchy_control_points I should get n*(6 components) I got n*(6
components)+2. The last two are not used because there are boundary
conditions (I do not get this but I need to read the paper you are citing,
and I cannot access it right now because I cannot reach sci hub...). The 6
components are from the 3 points, 2 intermediates, 1 finale. The finale is
the target right? So for get_hierarchy_control_points each [6n+4:6n+5]
coordinates are coordinates of a target in the hierarchical graph. But the
very last coordinates is the edge's target, isn't it?

I have the same question as Davide Cittaro.

I'm trying to create the same plot got from minimize_nested_blockmodel_dl and draw_hyerarch, but using the threejs
(https://threejs.org/docs/?q=curve#api/in/extras/curves/Quadratic Bezier Curve)

I'm using this code to extract the control points

state = gt.inference.minimize.minimize_nested_blockmodel_dl(g)
....
pos, t, tpos = state.draw(**options)
cts = gt.draw.get_hierarchy_control_points(g, t, tpos) 

However I couldn't get how the control points are enconded in the cts ds.

For example, a sinlge instance of cts object I have this

print(list(cts)[100] )
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.03 0.09
0.05 0.18 0.11 0.36 0.17 0.48 0.23 0.61 0.3 0.69 0.36 0.84 0.42 0.99
0.46 1.21 0.5 1.23 0.55 1.25 0.6 1.06 0.65 0.87 0.7 0.69 0.75 0.5
0.81 0.35 0.87 0.21 0.93 0.1 0.97 0.05 1. 0. 1. 0. 1. 0.
1. 0. 1. 0. 1. 0. ]

What's the meaning of the first 12 elements? How (x,y) for control points are encoded?

Best regards

From the documentation of graph_draw():

    control_points: Control points of a Bézier spline used to draw the
    edge. Each spline segment requires 6 values corresponding to the
    (x,y) coordinates of the two intermediary control points and the
    final point.

In the coordinate system, (0,0) is the start of the edge, and (1, 0) is
the end of the edge. The last point at (1,0) is always assumed, even if
not given.

(Note that the get_hierarchy_control_points() is wasteful, since it
includes duplicated points in the beginning and end. This is an outcome
of the translation between B-splines, used internally, and the Bezier
splines that are used for drawing. This is something I intended to fix,
but it seems I forgot.)

Best,
Tiago