342# define X(p) ((p)->get_key().x)
343# define Y(p) ((p)->get_key().y)
344# define PRE(p) ((p)->get_key().pre)
345# define MOD(p) ((p)->get_key().mod)
346# define SUMMOD(p) ((p)->get_key().sum_mod)
347# define STRING(p) ((p)->get_key().str)
348# define ISELLIPSE(p) ((p)->get_key().ellipse)
349# define ISRECTANGLE(p) ((p)->get_key().rectangle)
350# define XOFFSET(p) ((p)->get_key().xoffset)
351# define YOFFSET(p) ((p)->get_key().yoffset)
352# define XR(p) ((p)->get_key().xr)
353# define YR(p) ((p)->get_key().yr)
354# define XD(p) ((p)->get_key().xd)
355# define YD(p) ((p)->get_key().yd)
356# define POS(p) ((p)->get_key().position)
357# define MAXCHILDYR(p) ((p)->get_key().max_child_yr)
358# define YRGAP(p) ((p)->get_key().yr_gap)
359# define LEVEL(p) ((p)->get_key().level)
360# define CHILDNUMBER(p) ((p)->get_key().child_number)
361# define WIDTH(p) ((p)->get_key().xd)
362# define HEIGHT(p) ((p)->get_key().yd)
363# define SHADOW(p) ((p)->get_key().shadow)
364# define WITHOUTNODE(p) ((p)->get_key().without_node)
365# define WITHARC(p) ((p)->get_key().with_arc)
366# define DASHEDARC(p) ((p)->get_key().dashed_arc)
367# define ARCS(p) ((p)->get_key().arc_list)
368# define CONNEXIONS(p) ((p)->get_key().connexion_list)
369# define TAGS(p) ((p)->get_key().tag_list)
434 catch (
const std::out_of_range &)
449 while (c !=
'\n' and c !=
EOF);
535 if (
strcasecmp(buffer,
"DASHED-CONNEXION") == 0)
570 if (parent_node ==
nullptr)
611 parent_node->insert_rightmost_child(new_node);
670 if (tgt->get_parent() != src)
739 if (tgt->get_parent() == src)
890 catch (exception & e)
917 p = p->get_left_sibling())
919 if (
LEVEL(p) == level)
955 p = p->get_right_sibling())
957 if (
LEVEL(p) == level)
1002 assert(p->get_left_sibling() !=
nullptr);
1025 int level =
LEVEL(p) + 1;
1051 while (
l !=
nullptr and r !=
nullptr)
1091 if (p->is_leaf()
and p->is_leftmost())
1093 else if (p->is_leaf()
and p->is_root())
1113 if (p->is_leftmost()
or p->is_root())
1131 if (
not p->is_root())
1137 if (
not p->is_leftmost()
and not p->is_root())
1251 static int counter = 0;
1253 if (
root ==
nullptr)
1264 if (
root ==
nullptr)
1276 if (
root ==
nullptr)
1291 output <<
"start-prefix ";
1309 <<
"% This LaTeX picture is a tree automatically" <<
endl
1310 <<
"% generated by ntreepic program" <<
endl
1312 <<
"% Copyright (C) 2002, 2003, 2004, 2007" <<
endl
1313 <<
"% UNIVERSITY of LOS ANDES (ULA)" <<
endl
1314 <<
"% Merida - REPUBLICA BOLIVARIANA DE VENEZUELA" <<
endl
1315 <<
"% Center of Studies in Microelectronics & Distributed Systems"
1316 <<
" (CEMISID)" <<
endl
1317 <<
"% ULA Computer Science Department" <<
endl
1319 <<
"% Created by Leandro Leon - lrleon@ula.ve" <<
endl
1321 <<
"% This program uses the Sugiyama variation of Walker" <<
endl
1322 <<
"% algorithm for general trees drawing" <<
endl
1324 <<
"% You must use epic and eepic latex packages" <<
endl
1325 <<
"% in your LaTeX application" <<
endl
1327 <<
"% epic Copyright by Sunil Podar" <<
endl
1328 <<
"% eepic Copyright by Conrad Kwok" <<
endl
1329 <<
"% LaTeX is a collection of TeX macros created by Leslie Lamport"
1331 <<
"% TeX was created by Donald Knuth" <<
endl
1333 <<
"% command line: " <<
endl
1339 <<
"% Creation date: " <<
ctime(&t) <<
endl
1343 output <<
"\\documentclass[11pt]{article}" <<
endl
1345 <<
"\\usepackage{epic}" <<
endl
1346 <<
"\\usepackage{eepic}" <<
endl
1348 <<
"\\begin{document}" <<
endl
1349 <<
"\\begin{center}" <<
endl;
1355 <<
"\\begin{picture}(" <<
h_size <<
"," <<
v_size <<
")"
1364 <<
"\\end{picture}" <<
endl;
1368 <<
"\\end{center}" <<
endl
1369 <<
"\\end{document}" <<
endl;
1412 const bool left =
false,
1413 const bool is_dashed =
true)
1415 const long double &
px =
X(p);
1416 const long double &
py =
Y(p);
1418 const long double &
qx =
X(q);
1419 const long double &
qy =
Y(q);
1535 <<
" inside a forest ";
1539 long double x =
X(p);
1540 long double y =
Y(p);
1545 <<
"% Node at level " << level <<
". It's the "
1554 <<
"\\put(" << x <<
"," <<
YPIC(
y) <<
")"
1555 << (
SHADOW(p) ?
"{\\ellipse*{" :
"{\\ellipse{") <<
WIDTH(p)
1556 <<
"}{" <<
HEIGHT(p) <<
"}}";
1559 <<
"\\path(" << x -
XR(p) <<
"," <<
YPIC(
y -
YR(p)) <<
")"
1560 <<
"(" << x +
XR(p) <<
"," <<
YPIC(
y -
YR(p)) <<
")"
1561 <<
"(" << x +
XR(p) <<
"," <<
YPIC(
y +
YR(p)) <<
")"
1562 <<
"(" << x -
XR(p) <<
"," <<
YPIC(
y +
YR(p)) <<
")"
1563 <<
"(" << x -
XR(p) <<
"," <<
YPIC(
y -
YR(p)) <<
")";
1663 <<
"% Additional arc to child with key " <<
1694 for (
EepicNode *c = p->get_left_child(); c !=
nullptr;
1695 c = c->get_right_sibling())
1699 long double lx =
X(c);
1700 long double ly =
Y(c);
1736 long double lx =
X(c);
1737 long double ly =
Y(c);
1770 long double rx =
X(
rs);
1771 long double ry =
Y(
rs);
1818 "ntreepic 1.7 - ALEPH drawer for general rooted trees\n"
1819 "Copyright (C) 2004, 2007 UNIVERSITY of LOS ANDES (ULA)\n"
1820 "Merida - REPUBLICA BOLIVARIANA DE VENEZUELA\n"
1821 "Center of Studies in Microelectronics & Distributed Systems (CEMISID)\n"
1822 "ULA Computer Science Department\n"
1823 "This is free software; There is NO warranty; not even for MERCHANTABILITY\n"
1824 "or FITNESS FOR A PARTICULAR PURPOSE\n"
1831static char doc[] =
"ntreepic -- Aleph drawer for general rooted trees";
1834static char arg_doc[] =
"-f input-file [-o output-file]\n";
1838 "ALEPH drawer for general rooted trees\n"
1839 "Copyright (C) 2004, 2007 University of Los Andes (ULA)\n"
1840 "Merida - REPUBLICA BOLIVARIANA DE VENEZUELA\n"
1841 "Center of Studies in Microelectronics & Distributed Systems (CEMISID)\n"
1842 "ULA Computer Science Department\n"
1843 "This is free software; There is NO warranty; not even for MERCHANTABILITY\n"
1844 "or FITNESS FOR A PARTICULAR PURPOSE\n"
1849 "ALEPH drawer for general rooted trees. License & Copyright Note\n"
1850 "Copyright (C) 2004, 2007\n"
1851 "UNIVERSITY of LOS ANDES (ULA)\n"
1852 "Merida - REPUBLICA BOLIVARIANA DE VENEZUELA\n"
1853 "Center of Studies in Microelectronics & Distributed Systems (CEMISID)\n"
1854 "ULA Computer Science Department\n"
1855 "This is free software; There is NO warranty; not even for MERCHANTABILITY\n"
1856 "or FITNESS FOR A PARTICULAR PURPOSE\n"
1858 " PERMISSION TO USE, COPY, MODIFY AND DISTRIBUTE THIS SOFTWARE AND ITS \n"
1859 " DOCUMENTATION IS HEREBY GRANTED, PROVIDED THAT BOTH THE COPYRIGHT \n"
1860 " NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES OF THE \n"
1861 " SOFTWARE, DERIVATIVE WORKS OR MODIFIED VERSIONS, AND ANY PORTIONS \n"
1862 " THEREOF, AND THAT BOTH NOTICES APPEAR IN SUPPORTING DOCUMENTATION. \n"
1864 " This program is distributed in the hope that it will be useful,\n"
1865 " but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
1866 " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \n"
1868 " ULA requests users of this software to return to \n"
1869 " Proyecto Aleph - CEMISID Software\n"
1870 " Nucleo Universitario La Hechicera. Ed Ingenieria\n"
1871 " 3er piso, ala Este \n"
1872 " Universidad de Los Andes \n"
1873 " Merida 5101 - REPUBLICA BOLIVARIANA DE VENEZUELA \n"
1875 " or to lrleon@ula.ve \n"
1877 " any improvements or extensions that they make and grant Universidad \n"
1878 " de Los Andes (ULA) the full rights to redistribute these changes. \n"
1880 " This program was granted by: \n"
1881 " - Consejo de Desarrollo Cientifico, Humanistico, Tecnico de la ULA\n"
1892 "generate binary tree", 0
1896 "horizontal radius", 0
1900 "vertical radius", 0
1907 "horizontal offset for keys", 0
1911 "vertical offset for keys", 0
1913 {
"input-file",
'i',
"input-file", 0,
"input file", 0},
1915 {
"output",
'o',
"output-file", 0,
"output file", 0},
1918 "x-picture-offset",
'O',
"horizontal-picture-offset",
1922 "y-picture-offset",
'P',
"vertical-picture-offset",
1929 "Print version information and then exit", 0
1937 "draw linked list representation", 0
1941 "draw normal tree representation (or turn off linked list form)", 0
1957# define TERMINATE(n) (save_parameters(), exit(n))
1989 <<
"Global horizontal node radius -x = " <<
hr <<
endl
1990 <<
"Global vertical node radius -y = " <<
vr <<
endl
1991 <<
"Global horizontal node diameter = " <<
hd <<
endl
1992 <<
"Global Vertical node diameter = " <<
vd <<
endl
1993 <<
"Horizontal sibling separation -w = " <<
xgap <<
endl
1994 <<
"Vertical children separation -h = " <<
ygap <<
endl
1997 <<
"Horizontal global offset for key -X = " <<
x_offset <<
endl
1998 <<
"Vertical global offset for key -Y = " <<
y_offset <<
endl
2010 AH_ERROR(
"Waiting for radius in command line");
2016 AH_ERROR(
"Waiting for sibling gap in command line");
2021 AH_ERROR(
"Waiting for sibling gap in command line");
2026 AH_ERROR(
"Waiting for tree gap in command line");
2031 AH_ERROR(
"Waiting for horizontal radius in command line");
2037 AH_ERROR(
"Waiting for vertical radius in command line");
2043 AH_ERROR(
"Waiting for resolution in command line");
2046 cout <<
"Warning: resolution too big" <<
endl;
2058 AH_ERROR(
"Waiting for horizontal offset in command line");
2063 AH_ERROR(
"Waiting for vertical offset in command line");
2068 AH_ERROR(
"Waiting for horizontal offset in command line");
2073 AH_ERROR(
"Waiting for vertical offset in command line");
2082 AH_ERROR(
"Waiting for input file name");
2088 AH_ERROR(
"Waiting for output file name");
2134 AH_ERROR(
"Waiting for arrow lenght in command line");
2140 AH_ERROR(
"Waiting for arrow width in command line");
2178 if (pos != string::npos)
Exception handling system with formatted messages for Aleph-w.
#define ah_overflow_error_if(C)
Throws std::overflow_error if condition holds.
#define ah_invalid_argument_if(C)
Throws std::invalid_argument if condition holds.
#define AH_ERROR(format, args...)
Print an error message (always enabled).
Dynamic doubly linked list with O(1) size and bidirectional access.
T & append(const T &item)
Append a new item by copy.
bool tiny_keys
Global flag to enable tiny font size for keys/labels.
__gmp_expr< T, __gmp_binary_expr< __gmp_expr< T, U >, unsigned long int, __gmp_root_function > > root(const __gmp_expr< T, U > &expr, unsigned long int l)
void destroy_tree(Node *root)
Destroys (frees memory) the tree whose root is root.
void tree_postorder_traversal(Node *root, void(*visitFct)(Node *, int, int))
Postorder traversal of a tree.
void tree_preorder_traversal(Node *root, void(*visitFct)(Node *, int, int))
Preorder traversal of a tree.
Node * deway_search(Node *root, int path[], const size_t &size)
Returns a node of a forest given its Dewey number.
void init_token_scanning()
Initialize token scanning by recording current position.
void close_token_scanning(const char *buffer, char *&start_addr, const char *end_addr)
Finalize token scanning by null-terminating and saving the token.
int read_char_from_stream(std::ifstream &input_stream)
Read a single character from an input stream with position tracking.
void print_parse_error_and_exit(const std::string &str)
Print a parse error message and terminate the program.
void put_char_in_buffer(char *&start_addr, const char *end_addr, int c)
Append a character to a buffer with bounds checking.
std::string command_line_to_string(int argc, char *argv[])
Convert command line arguments to a single string.
void skip_white_spaces(std::ifstream &input_stream)
Skip whitespace characters in the input stream.
constexpr size_t Buffer_Size
Default buffer size for token parsing.
std::string load_string(std::ifstream &input_stream)
Load a string from the input stream.
DynList< T > maps(const C &c, Op op)
Classic map operation.
void print_parse_warning(const std::string &str)
Print a parse warning message.
long load_number(std::ifstream &input_stream)
Load an integer number from the input stream.
T sum(const Container &container, const T &init=T{})
Compute sum of all elements.
void parse_rectangle(ifstream &input_stream, EepicNode *root)
EepicNode * __advance_to_leftmost_in_level(EepicNode *root, const int level, long double &sum)
EepicNode * parse_deway_number(ifstream &input_stream, EepicNode *root)
void compute_coordinates_for_forest_and_set_picture_size(EepicNode *root)
bool draw_list_representation
const char * parameters_file_name
Token_Type get_token(ifstream &input_stream)
void generate_tree(ofstream &output, EepicNode *p, int level, int child_index)
void adjust_minimal_separation_with_letf_sibling(EepicNode *p)
void shift_tree_to_right(EepicNode *p, int, int)
void parse_xoffset(ifstream &input_stream, EepicNode *root)
void generate_forest(ofstream &output, EepicNode *root)
void precompute_x_for_node(EepicNode *p, const int level, const int child)
void parse_connexion(ifstream &input_stream, EepicNode *root)
static error_t parser_opt(int key, char *arg, struct argp_state *)
void precompute_x_coordinates_for_tree(EepicNode *root)
void generate_curve(ofstream &output, EepicNode *p, EepicNode *q, const bool left=false, const bool is_dashed=true)
EepicNode * parse_first_root_definition(ifstream &input_stream)
void parse_arc(ifstream &input_stream, EepicNode *root)
void parse_without_arc(ifstream &input_stream, EepicNode *root)
void generate_epilogue(ofstream &output)
void parse_shadow(ifstream &input_stream, EepicNode *root)
void generate_prefix_traversal(ofstream &output, EepicNode *root)
std::string input_file_name
void generate_infix_traversal(ofstream &output, EepicNode *root)
long double x_picture_offset
const char * argp_program_version
void parse_vradio(ifstream &input_stream, EepicNode *root)
Tree_Node< Tree_Data > EepicNode
EepicNode * read_input_and_build_tree(ifstream &input_stream)
void parse_ellipse(ifstream &input_stream, EepicNode *root)
bool generate_binary_tree
EepicNode * parse_key_node_and_allocate(ifstream &input_stream)
EepicNode * allocate_node(const string &str)
void parse_yoffset(ifstream &input_stream, EepicNode *root)
static const char license_text[]
std::string output_file_name
EepicNode * __advance_to_rightmost_in_level(EepicNode *root, const int level, long double &sum)
void parse_hradio(ifstream &input_stream, EepicNode *root)
EepicNode * advance_to_leftmost_in_level(EepicNode *root, const int level, long double &sum)
void parse_node_definition(ifstream &input_stream, EepicNode *root)
void parse_without_node(ifstream &input_stream, EepicNode *root)
const char * argp_program_bug_address
void compute_coordinates_for_tree(EepicNode *root)
void load_deway_number(ifstream &input_stream, int deway_array[], size_t deway_array_size)
static struct argp_option options[]
void parse_tag(ifstream &input_stream, EepicNode *root)
void generate_bin_tree(ofstream &output, EepicNode *root)
static const char * hello
void parse_dashed_arc(ifstream &input_stream, EepicNode *root)
void compute_definitive_coordinates_for_node(EepicNode *p, int, int)
long double y_picture_offset
void infix_tree(EepicNode *root)
void generate_prologue(ofstream &output)
EepicNode * advance_to_rightmost_in_level(EepicNode *root, const int level, long double &sum)
static struct argp arg_defs
void parse_root_definition(ifstream &input_stream, EepicNode *root)
Comprehensive parsing utilities for text processing and compiler construction.
Tag_Data(string str, const Tag_Option option)
DynDlist< Connexion_Data > connexion_list
DynDlist< Arc_Data > arc_list
DynDlist< Tag_Data > tag_list
Lazy and scalable dynamic array implementation.
Dynamic doubly linked list implementation.
General tree (n-ary tree) node.
Tree picture generation utilities.
void intersection_ellipse_line(long double lx0, long double ly0, long double lx1, long double ly1, long double a, long double b, long double &dx, long double &dy)
void put_string(std::ofstream &output, const long double &x, const long double &y, const std::string &comment, const std::string &str)
long double string_width(const std::string &str)
void draw_arc(std::ofstream &output, long double src_x, long double src_y, long double tgt_x, long double tgt_y, bool is_dashed, bool with_arrow, bool thick=true)
void intersection_rectangle_line(long double lx0, long double ly0, long double lx1, long double ly1, long double a, long double b, long double &dx, long double &dy)
long double font_height()
long double YPIC(long double y)
long double center_string(const std::string &str, long double window_size)