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
Built Distribution
File details
Details for the file smallgraphlib-0.6.3.tar.gz
.
File metadata
- Download URL: smallgraphlib-0.6.3.tar.gz
- Upload date:
- Size: 30.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.10.4 Linux/5.19.0-76051900-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2021048d4854c370aca12d9b1e5210e63ee36dae77c6bbd94ecb33e17ac4ece0 |
|
MD5 | 6af4f903f4762fb3c5e44f953cd24ca3 |
|
BLAKE2b-256 | c59c3036860af18d200a695524e45f8e82c2d01da722ba33b19ef5462f5d31c3 |
File details
Details for the file smallgraphlib-0.6.3-py3-none-any.whl
.
File metadata
- Download URL: smallgraphlib-0.6.3-py3-none-any.whl
- Upload date:
- Size: 33.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.10.4 Linux/5.19.0-76051900-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90b41c3c524ee846b931cb85dcf937e79b8d585a844922deeca2fb1afa2e5084 |
|
MD5 | 01999eee99b2b98fc76236ff137995d3 |
|
BLAKE2b-256 | a91a621fe5dfc9217c016e5eef08bf585024419304e4ebb32a54da106af67f0e |