Skip to content

neilSchroeder/dependency-mapping

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dependency Visualizer

A Python tool for visualizing dependencies between modules in Python projects.

Components

  • mapper.py: Analyzes Python projects and generates dependency graphs
  • visualizer.py: Interactive GUI for visualizing dependency relationships

Features

  • Static analysis of Python module dependencies
  • Interactive graph visualization
  • Multiple layout options (Kamada-Kawai, Spring, Circular)
  • Directory-based color coding
  • Click-to-highlight dependencies
  • Zoom and pan capabilities

Examples

Here are some examples of features the author finds most useful, and an explanation of each.

  1. Circular Layout (default)

Circular Layout

This layout emphasizes cyclic dependencies and provides a clear overview of module relationships. Each node represents a python file found in the package, and each node is colored by its parent folders.

  1. Node Select

Circular Layout

Nodes can be selected by clicking on them. Selected nodes show up in bold white text, it's neighbors will show up in larger white font. All other nodes are pushed to the background.

Blue arrows represent import calls by other files, i.e. in <other_file.py> you will find some version of import <selected> or from <selected> import <foo>. Red arrows represent dependencies, i.e. in <selected.py> you fill find a import <other_file.py> or from <other_file.py> import <bar>.

  1. Layout Selector

Multipartite Layout

The layout of the nodes can be changed to a range of options. The most useful tend to be Circular, Arf, and Multipartite (which is structured by the folder structure of the project). Changing layout preserves the state of the graph and does not clear selections.

  1. Color Change Button

Multipartite Layout

The color scheme of the nodes can be changed to be more appealing by pressing the "Change Color" button. The color scheme is regenerated using a variation of saturations and values, and repeatedly increasing the hue by the golden ratio and taking its remainder from 1: new_hue = old_hue + 0.618033988749895 % 1.0. This guarantees that no two colors will be identical for an extremely large set of numbers. However, the cyclical nature of the operation can result in color schemes which are similar and the user may need to cycle color schemes several times to find an appealing option.

Requirements

  • Python 3.11
  • PyQt5
  • matplotlib
  • networkx
  • scipy
  • ruff
  • pre-commit
  • mypy
  • setuptools

Installation

This project uses uv to manage packages and virtual environments.

curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync
source .venv/bin/activate

Usage

  1. Run the mapper to analyze your project:
python src/mapper.py --path <path/to/directory/to/analyze> --output <tag_for_output>

the output will be written to cfg/<tag_for_output>.txt

  1. Launch the visualizer:
python src/visualizer.py
  1. Click "Load Dependencies" and select the cfg/<tag_for_output>.txt file

License

MIT License

Author

Neil Schroeder

About

Tools for mapping and visualizing dependency structure in python projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages