Simple library for handling small graphs, including Tikz code generation.
Project description
Small Graph Lib
Installing
$ git clone https://github.com/wxgeo/smallgraphlib
$ pip install --user smallgraphlib
Usage
Main 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
True
Special 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
2
If the graph is not too complex, Tikz code may be generated:
>>> g.as_tikz()
...
Development
-
Get last version:
$ git clone https://github.com/wxgeo/smallgraphlib
-
Install Poetry.
Poetry is a tool for dependency management and packaging in Python.
Installation instructions are here: https://python-poetry.org/docs/#installation
-
Install developments tools:
$ poetry install
-
Optionally, update development tools:
$ poetry update
-
Optionally, install library in editable mode:
$ pip install -e smallgraphlib
-
Make changes, add tests.
-
Launch tests:
$ tox
-
Everything's OK ? Commit. :)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
smallgraphlib-0.7.1.tar.gz
(32.8 kB
view hashes)
Built Distribution
Close
Hashes for smallgraphlib-0.7.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b95c92b26f37bf212682abf363766d2cb3eb11e4c5f6d086a1a778c6df13ffb |
|
MD5 | 292f6b70e17338df60618ff42f94e4e0 |
|
BLAKE2b-256 | 071e2164e28adf7e9ea7f400bc438037b0cd8120f3e0df515b5a7dd84d0c27cf |