Skip to main content

A Python package for forest structure visualization and traversals

Project description

Forest Visualizer

forest-visualizer is a Python package that provides tools for building and visualizing forest data structures using Turtle Graphics. This package allows users to perform operations like inserting nodes, tree traversal (pre-order, post-order, and level-order), deleting nodes, and drawing the forest structure visually.

Background

This package implements a forest visualization algorithm based on the paper Novel Static Multi-Layer Forest Approach and Its Applications published in MDPI. The paper provides detailed insights into the theoretical foundations of the algorithm.

Features

  • Tree Insertion: Insert parent-child relationships to build a forest structure.
  • Tree Traversal: Perform pre-order, post-order, and level-order traversals of the forest.
  • Node Deletion: Remove nodes and automatically adjust the tree structure.
  • Visual Representation: Use Turtle Graphics to draw the forest with customizable node sizes and gaps.
  • Path Finding: Find the path from any node to the root.

Installation

You can install the forest-visualizer package directly from PyPI:

pip install forest-visualizer

Example Python Code

from forest_visualizer import Forest
# Example usage
forest = Forest()

# Inserting nodes
forest.insert('40', 'N/A')
forest.insert('50', '40')
forest.insert('30', '40')
forest.insert('35', '30')
forest.insert('25', '30')
forest.insert('28', '25')
forest.insert('15', '25')
forest.insert('60', '50')
forest.insert('45', '50')
forest.insert('70', '60')
forest.insert('55', '60')


forest.level_traversal()
forest.display()
print(forest.find_parent('25'))
print(forest.find_path_to_root('15'))
#Perform pre-order traversal and print the result
pre_order_result = forest.pre_order_traversal('40')
print("Pre-order traversal result:", pre_order_result)

#Perform pre-order traversal and print the result
post_order_result = forest.post_order_traversal('40')
print("Post-order traversal result:", post_order_result)
forest.draw_tree()
forest.delete_node('25')
forest.draw_tree()
forest.insert('90', '35')
forest.draw_tree()

Output Fileenter image description here

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

forest-visualization-0.1.3.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

forest_visualization-0.1.3-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file forest-visualization-0.1.3.tar.gz.

File metadata

  • Download URL: forest-visualization-0.1.3.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.43.0 importlib-metadata/3.10.1 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.9

File hashes

Hashes for forest-visualization-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7ca5bceb088dd904096c9a15b4e0b84c372cd5760f535aa30e4a2b7d77e57faf
MD5 4684324c84ad4ec11a851634ebf24204
BLAKE2b-256 3f3d3b91c71b00ebd50d3f3093ee497ebe915f4dc44bd004f09249ea721d17b1

See more details on using hashes here.

File details

Details for the file forest_visualization-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: forest_visualization-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.43.0 importlib-metadata/3.10.1 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.9

File hashes

Hashes for forest_visualization-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d8eb22d1d2c6e7cc50dc2665d6864186475f923f255942b8a416c4368020a26b
MD5 023d315f9b1f59718393603cf6fb00db
BLAKE2b-256 0ab61f1115a3632ca42416778de6be0689a7a586e5a0dc528840030191002624

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page