Type Annotated Graphs in Python
This is not a graph library! It is just the source code for a series of blog articles. It's not tested as extensively as a library should be, and it's also not optimized in any way.
If you do want to use it in your project, the most reasonable implementations are:
The blog posts are here:
- Part I - Representing graphs as dictionaries or sets
- Part II - Representing graphs as classes
- Part III - Implementing graph traversal
- Part IV - Trees
They summarize my experience with type hints in a small project. I go through several iterations of graph representation and traversal, and discuss various design and type checking issues. I use python 3.6 and the latest version of mypy.
My workflow used to be:
- push my code to this repo to run tests / type checker using Travis CI
- push it to gist, from which it is directly embedded in the blog
It was a good way to test the code shown in the posts. Later, I needed to use this code myself, so I rearranged the folder structure as if it was a regular package. Unfortunately, it means I can't push the entire thing to gist any more.