Metadata-Version: 2.4
Name: easytreevis
Version: 1.0.0
Summary: Package for easy visualisation of trees in Python
Author-email: Michał Gomułczak <michal.gomulczak1@gmail.com>
License: MIT License
        
        Copyright (c) 2025 denchal
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: svgwrite>=1.4.3
Dynamic: license-file

# Easy Tree Visualization Library
The goal of this mini-project is to provide an easy, customizable way to create visualizations of tree structures, without use of `networkx` or similar. <br>


## What this library is
A way to parse a tree in **adjacency dictionary**, or list format and visualize it with a `.svg` file.
It supports various objects as node labels, with easily overridable way to include any object data representable as string as node label. This was done mainly with allowing easy visualization of MCTS search trees in mind. It also allows easy sorting of the nodes, by id, it's properties or object's properties. Id can also be an object, e.g. MCTS State custom timestamp class.

## What it is not
This is **not** a library for storing, modifying, or parsing trees -- let alone graphs.

## Usage
Example use of the library:
```python
    tree_data = {
        "A": ["B", "C", "G"],
        "B": ["D", "E"],
        "C": ["F"],
        "D": [], "E": [], "F": [], 
        "G": ["H"],
        "H": ["I"],
        "I": ["J"],
        "J": ["K", "L"],
        "K": [], "L": []
    }
    tree = Tree.from_dict(tree_data)
    draw_tree(tree, "tree.svg")
```
Result: <br>
![tree](tree.svg) <br>
Please visit `examples/` directory for a few more examples, including customization, node ordering and visualizing different objects.

## Customization
Available parameters include:
```
    NODE_RADIUS
    FONT_SIZE
    EDGE_STROKE - color of lines between nodes
    EDGE_STROKE_WIDTH - width of line between nodes
    FILL_NODE - node fill color, per svgwrite.Drawing
    STROKE_NODE - color of node border
    STROKE_NODE_WIDTH - width of node border
    X_SPACING - minimum spacing between nodes in the same row
    Y_SPACING - minimum spacing between nodes in different rows
    MARGIN - margin around entire tree, as the image is cut to width+margin by height+margin
    TEXT_OFFSET - offset from middle of the node
```

## Performance
While not specifically optimized for performance, the library is capable of handling large trees (e.g., >5000 nodes) in a few seconds.
