PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/ComputerAlgebra/Trees/Lisp/docus/Tutorial.hpp

https://github.com/exp04shy/oklibrary
C++ Header | 111 lines | 0 code | 2 blank | 109 comment | 0 complexity | 47ec03f857c929f35acbf87d557dca7d MD5 | raw file
  1. // Rui Wang, 21.11.2009 (Swansea)
  2. /* Copyright 2009 Oliver Kullmann
  3. This file is part of the OKlibrary. OKlibrary is free software; you can redistribute
  4. it and/or modify it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation and included in this library; either version 3 of the
  6. License, or any later version. */
  7. /*!
  8. \file ComputerAlgebra/Trees/Lisp/docus/Tutorial.hpp
  9. \brief Tutorial on trees in Maxima/Lisp
  10. <h1> %Trees via Maxima in the OKlibrary </h1>
  11. <ol>
  12. <li> For the OKlibrary, An "unlabelled rooted tree" ("rt") is recursively
  13. defined as a list [T_1, ..., T_n], where the T_i are the subtrees (the case
  14. n=0, i.e., the empty list, represents the trivial tree).
  15. \verbatim
  16. (%i1) T:[[],[[],[]]];
  17. (%o1) [[],[[],[]]]
  18. \endverbatim
  19. </li>
  20. <li> Similarly, a "labelled rooted tree" ("lrt") is recursively defined as a
  21. list [L, T_1, ..., T_n], n >= 0, where L is the label, and the T_i are the
  22. subtrees.
  23. \verbatim
  24. (%i2) T:[1,[2],[3,[4],[5]]];
  25. (%o2) [1,[2],[3,[4],[5]]]
  26. \endverbatim
  27. </li>
  28. </ol>
  29. <h1> Tree drawing algorithm </h1>
  30. <ul>
  31. <li> Currently, Reingold-Tilford algorithm is used for producing layered
  32. tree drawing. we implemented reingold_tilford_rt in Maxima.
  33. Given an unlabelled rooted tree and the root coordinate as input, a
  34. labelled rooted tree with 2-dimensional coordinates will be produced.
  35. \verbatim
  36. (%i27) reingold_tilford_rt([[],[]],[0,0]);
  37. (%o27) [[[0,0]],[[[-1,-1]]],[[[1,-1]]]]
  38. \endverbatim
  39. </li>
  40. </ul>
  41. <h1> Visualisation of trees </h1>
  42. <ul>
  43. <li> Both unlabelled and labelled rooted trees can be handled and visualised via Maxima in the OKlibrary. For splitting trees we use a different function to handle them. A splitting tree is a labelled rooted tree, where each inner node is labelled by a number (natural number) while leaves are labelled by the boolean values 'true' or 'false'. In the following part, we will give the detailed usage of tree drawing functions.
  44. <ol>
  45. <li> draw_rt
  46. <ul>
  47. <li> draw_rt can handle unlabelled rooted trees; at least one argument (an unlabelled rooted tree T) must be given, all other possible parameters are optional. The default value will be set if any optional parameter is not given.
  48. </li>
  49. <li> Possible parameters are listed as follows:
  50. <ul>
  51. <li> T : an unlabelled rooted tree. </li>
  52. <li> p : the root coordinates of the tree [x,y]; default [0,0]. </li>
  53. <li> xran : the range for the x coordinate [x_min,x_max]; default auto. </li>
  54. <li> yran : the range for the y coordinate [y_min,y_max]; default auto. </li>
  55. <li> pts : the size of a point (a non-negative number); default computed. </li>
  56. <li> ptt : the type of points (either as name or as integer). Available names and integers are: $none (-1), dot (0), plus (1), multiply (2), asterisk (3), square (4), filled_square (5), circle (6), filled_circle (7) *default*, up_triangle (8), filled_up_triangle (9), down_triangle (10), filled_down_triangle (11), diamant (12), filled_diamant (13).
  57. </li>
  58. <li> ptc : the colour of points (red, blue, ...); default red. </li>
  59. <li> edgc : the colour of edges (red, blue, ...); default blue. </li>
  60. <li> output: if output is set to "true", the tree drawing will be output to a file called "output.eps" in the current directory. Otherwise, the tree drawing will be displayed normally. </li>
  61. </ul>
  62. </li>
  63. <li> T is a compulsory parameter that can be accepted by a function call in the following ways:
  64. <ol>
  65. <li> Set T in global (e.g. T:value; then, draw_rt()). </li>
  66. <li> Use "T:value" as an argument. (e.g. draw_rt(T:value)). </li>
  67. <li> Use the "value" of T as the first argument. (e.g. draw_rt(value)). </li>
  68. </ol>
  69. The other parameters are optional, the usage of which are similar to the
  70. parameter T which is listed above except 3. Furthermore, the optional
  71. parameters can be set to "unknown" (e.g. draw_rt(pts:unknown)) so that
  72. the default values of the parameters will be used.
  73. </li>
  74. </ul>
  75. </li>
  76. <li> draw_lrt
  77. <ul>
  78. <li> draw_lrt handles labelled rooted trees. RGB colour model is used for the colouring schemes. The usage of the function is similar to draw_rt except the compulsory parameter T which is a labelled rooted tree here. (Please refer to draw_rt).
  79. </li>
  80. </ul>
  81. </li>
  82. <li> draw_st
  83. <ul>
  84. <li> draw_st is used for visualising splitting trees. For visualisation of splitting trees, we just print the labels of inner nodes up to depth d, where d is a natural number >= -1, and for the inner nodes of depth <= d then the labels are printed, while otherwise nothing shows. Leaves are treated differently, where the leaves that are labelled by "true" show the node-symbol with red colour, otherwise grey colour.
  85. For draw_st, the compulsory parameter T is a splitting tree. Some optional parameters are listed below:
  86. <ul>
  87. <li> lbc : the colour of labels; default red. </li>
  88. <li> tc : the colour of true-leaves; default red. </li>
  89. <li> fc : the colour of false-leaves; default grey. </li>
  90. <li> d : the maximum depth which the labels will be printed. (d is a natural number >= -1). </li>
  91. </ul>
  92. For the usage and other possible parameters, please refer to draw_rt.
  93. </li>
  94. </ul>
  95. </li>
  96. </ol>
  97. </li>
  98. </ul>
  99. */