Visualisation.hpp File Reference

Plans regarding visualisation of trees. More...

Go to the source code of this file.

Detailed Description

Plans regarding visualisation of trees.

False labels at the leaves
  • The following needs to be updated; see also "Specify draw_lrt" below.
  • draw_rt creates labels at the leaves, which makes no sense for trees where the leaves have no labels.
  • So it has no place in "draw_rt" which is about *unlabelled* trees.
  • There needs to be another version, "draw_lrt", which takes labels into account.
  • And printing out the labels is a bad idea --- it's just unreadable.
  • Obviously, for leaf-labels with two possibilities, one should just use shape and/or colour for the leaves to differentiate the two possibilities.
  • It seems the function should not just be called "draw_lrt", but "draw_lrt_X", where X gives information on the special assumptions about the labels: For different assumptions one has different drawing functions.
  • For example "draw_lrt_bl" for boolean at the leaves (while labels for inner nodes are currently ignored.
  • Actually, a reasonable easy way to show the labels at (arbitrary) nodes is just to print them instead the node-symbols; one should use an additional parameter d, a natural number >= -1, and for nodes of depth <= d then the label is printed, while otherwise the (normal) node-symbol is shown.
  • So we would have "draw_lrt_d", where the labels of nodes are just printed up to depth d, and "draw_lrt_dbl", which treats the leaves differently (requiring the labels there of special form, namely just booleans, and showing them out graphically).
  • In order to be able to cope with labels, obviously we also need a version reingold_tilford_lrt, which just ignores the labels, but keeps them*.
Specify draw_lrt
  • What are the requirements on the node-labels of T?
  • There needs to be a general version which just accepts arbitrary terms as labels.
  • Compare with "False labels at the leaves" above.
  • Likely "draw_lrt" shouldn't make any assumptions on the labels, only more specialised versions perform special drawings.
  • Especially we need a version which doesn't make a special case for leaves.
Better organisation
Create milestones
DONE A basic example of visualising a tree using Gnuplot
  • The coordinates of points used in this example are produced by the Reingold-Tilford algorithm; for the details please refer to ComputerAlgebra/Trees/Lisp/plans/ReingoldTilford.hpp.
  • Define p as a list of points:
       p: points([[0,0],[-2,-1],[2,-1],[-3,-2],[-1,-2],[1,-2],[3,-2],[-4,-3],
  • Define a 2-dimensional drawing scene:
       s: gr2d(xrange = [-15,15],
       yrange = [-8,8],
       point_size = 4,
       point_type = circle,
       color = red,
       line_width = 1,
  • Perform the drawing using "draw(s);".
  • The task is now, given a tree labelled with 2-dimensional coordinates, to extract this data algorithmically. For that it would be helpful to have more explanations on the above.
DONE Full implementation of tree drawing using Gnuplot
  • In the basic example, all points and edges must be specified manually. For the requirement of algorithmically extracting the data of points and edges from the results of reingold_tilford_rt, tdlrt2points and tdlrt2deges are provided. Then the extracted data can be used by draw_rt to perform tree drawing.
  • The usage of draw_rt.
    • The function takes two parameters, the first one must be a binary unlabelled rooted tree; the second one is a list containing drawing attributes. If an empty list [] is provided, the automatic computation and drawing will be performed. Otherwise, the drawing attributes in the list can be defined as [name_1, value_1, ... , name_N, value_N], n >= 0. Each attribute contains two fields, which are name and value, both of which must be provided. Possible attribute names are 'root', 'x_ran', 'y_ran', 'p_size', 'p_type', 'p_colour', 'e_colour'. The details are listed below.
      1. root: the root coordinates which is a list [x,y] contains a pair of coordinates.
      2. x_ran: the range for the x coordinate which is a list [x_min,x_max] contains a pair of extreme x coordinates.
      3. y_ran: the range for the y coordinate which is a list [y_min,y_max] contains a pair of extreme y coordinates.
      4. p_size: the points size, it must be a non-negative number. (eg. 0, 1, 3.4)
      5. p_type: the points type. (Possible values: dot, plus, multiply, asterisk, square, filled_square, circle, filled_circle, up_triangel, filled_up_triangle, down_triangle, filled_down_triangle, diamant, filled_diamant).
      6. p_colour: the points colour. Colours can be given as names or in hexadecimal rgb code "#rrggbb".
      7. e_colour: the edges colour. Colours can be given as names or in hexadecimal rgb code "#rrggbb".
    • Somes examples: draw_rt([[],[]],[]); draw_rt([[],[[],[]]],[root,[1,1]]).
Colouring schemes
  • Handle labelled trees where the labels are lists of values (constant length). Now the label is a list which contains just one value.
  • Investigate RGB colour model which will be used for the colouring schemes.
  • "draw_lrt_X", where X gives information on the special assumptions about the labels: For different assumptions one has different drawing functions.

Definition in file Visualisation.hpp.