aboutsummaryrefslogtreecommitdiff
path: root/Computer_Science/data_structures/chapter_4/print_ascii_tree.h
blob: 1ddfa3b8dec737c0e93557ee41937e7a26ab69cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
** !!!Code originally from /http://www.openasthra.com/c-tidbits/printing-binary-trees-in-ascii/
** !!! Just saved it, cause the website is down.
** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
** I use it here for learning.
*/
#ifndef _PRINT_ASCII_TREE_H
#define _PRINT_ASCII_TREE_H

struct asciinode_struct;
typedef struct asciinode_struct asciinode;

#define MAX_HEIGHT 1000

#ifndef INFINITY
#define INFINITY (1 << 20)
#endif

int MIN (int X, int Y);
int MAX (int X, int Y);
asciinode *build_ascii_tree_recursive(Tree t);
asciinode *build_ascii_tree(Tree t);
void free_ascii_tree(asciinode *node);
void compute_lprofile(asciinode *node, int x, int y);
void compute_rprofile(asciinode *node, int x, int y);
void compute_edge_lengths(asciinode *node);
void print_level(asciinode *node, int x, int level);
void print_ascii_tree(Tree t);

#endif