Smallgraphlib is on PyPI, so you can download and install it with pip, as any usual python package.
pip install smallgraphlibFor development, please clone the last version from Github:
git clone https://github.com/wxgeo/smallgraphlibYou will then need uv to manage the development process.
If needed, install it on Linux or Mac with:
curl -LsSf https://astral.sh/uv/install.sh | shMore information on uv installation
It is also recommended to install just command runner, to execute
the recipes of the justfile.
uv tool install rust-justMain classes are Graph, DirectedGraph, WeightedGraph and WeightedDirectedGraph:
>>> from smallgraphlib import DirectedGraph
>>> g = DirectedGraph(["A", "B", "C"], ("A", "B"), ("B", "A"), ("B", "C"))
>>> g.is_simple
True
>>> g.is_complete
False
>>> g.is_directed
True
>>> g.adjacency_matrix
[[0, 1, 0], [1, 0, 1], [0, 0, 0]]
>>> g.degree
3
>>> g.order
3
>>> g.is_eulerian
False
>>> g.is_semi_eulerian
TrueSpecial graphs may be generated using factory functions:
>>> from smallgraphlib import complete_graph, complete_bipartite_graph
>>> K5 = complete_graph(5)
>>> len(K5.greedy_coloring)
5
>>> K33 = complete_bipartite_graph(3, 3)
>>> K33.degree
6
>>> K33.diameter
2If the graph is not too complex, Tikz code may be generated:
>>> g.as_tikz()
...-
Install dependencies including development tools:
uv sync- Optionally, update dependencies and development tools:
uv sync --upgrade- Optionally, install library in editable mode:
uv pip install -e smallgraphlib-
Make changes, add tests.
-
Launch tests:
just test- Everything OK? Commit. :)