Skip to content

cning112/dictionary_graph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dictionary Graph

Design

This module can be used to draw a dictionary as a tree graph. The graph layout is computed using Buchheim algorithm. Based on the computed layout, this module provides a few layout directions to start with, including top-bottom, bottom-top, left-right, right-left, and radial.

Top to bottom layout

From top to bottom

Bottom to top layout

From bottom to top

Left to right layout

From left to right

Right to left layout

From right to left

Radial layout

Radial

Usage

There are two ways to draw dictionary graphs.

CLI

One is to use it in CLI following the below steps.

$ pip install -e .
$ draw_dict --infile assets/example_words.txt --rankdir=TB --outfile top_bottom.png --dpi 300 --figsize 16 10
$ draw_dict --infile assets/example_words.txt --rankdir=BT --outfile bottom_top.png --dpi 300 --figsize 16 10
$ draw_dict --infile assets/example_words.txt --rankdir=LR --outfile left_right.png --dpi 300 --figsize 10 16
$ draw_dict --infile assets/example_words.txt --rankdir=RL --outfile right_left.png --dpi 300 --figsize 10 16
$ draw_dict --infile assets/example_words.txt --rankdir=RADIAL --outfile radial.png --dpi 300 --figsize 16 16

As a Python module

Alternatively, you can use it as a py module. See main.py or the below code for an example. This function provides finer control over the graph such as node size, color, etc.

# main.py
from dict_graph import draw_dictionary_graph

if __name__ == "__main__":
    with open("assets/example_words.txt") as fp:
        words = fp.read().splitlines()

    draw_dictionary_graph(words)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages