/TOWFM

Create a data structure of any kind of tree.

Primary LanguagePythonMIT LicenseMIT

Logo

TOWFM

What is TOWFM?

TOWFM is a flexible and convenient Python module for creating various tree data structures.

Installing TOWFM

The module supports the latest python version (3.9).

Command:

pip3 install TOWFM

Test run

After installing the module, you can start generating the Binary Tree.

Command:

from towfm.BTT import run

run()

The result will be saved in the test_tree.js file.

Create WikiTree

from towfm.WT import CreateWT

a = CreateWT('hello world')
a.handle()

Create binary search tree

from towfm import BinaryTree

a = BinaryTree(5, [2, 6, 3]) #1 way

a = BinaryTree(5) #2 way
a.append([2, 6, 3])

a = BinaryTree() #3 way
a.append(5)
a.append(2)
a.append(6)
a.append(3)

a.processed_tree #Returns a tree without extra nodes

Create your own tree

from towfm import CreateTree

a = CreateTree('a', list(range(10))) #1 way

a = CreateTree('a') #2 way
a.add(0, list(range(10)))

a = CreateTree() #3 way
a.add_root_node('a', list(range(10)))

a = CreateTree() #4 way
a.add_root_node('a')
a.add(0, list(range(10)))

a = CreateTree('a') #5 way
for i in range(10):
    a.add(0, i)

Tree output

First way:

Outputs the tree dictionary (main).

a = CreateTree('a', list(range(10)))
print(a.tree)

Second way:

Output of the CreateTree class.

a = CreateTree('a', list(range(10)))
print(a)

This method displays only part of the tree and additional information.

Third way:

Prints the tree in an understandable format.

a = CreateTree('a', list(range(10)))
a.pt()