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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smallgraphlib-1.1.0.tar.gz.
File metadata
- Download URL: smallgraphlib-1.1.0.tar.gz
- Upload date:
- Size: 44.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.2 Linux/6.1.0-28-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd072cbd3d03f3ea31d40decb0c75a5e50afa57eaceca5312bd7ad6865460e2a
|
|
| MD5 |
0a6804f8b9c94c86c4a91b82b7452c68
|
|
| BLAKE2b-256 |
d3f43435381dcf430d28bb5264aef116255dc4ffb177a3fc3dc2c4b0a946fff7
|
File details
Details for the file smallgraphlib-1.1.0-py3-none-any.whl.
File metadata
- Download URL: smallgraphlib-1.1.0-py3-none-any.whl
- Upload date:
- Size: 50.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.2 Linux/6.1.0-28-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37386a99b76addcd36d08051f4d1acc5555ffc0369230aa5cd0a95a88ee3e403
|
|
| MD5 |
37089f627570a2de86cb2fc31bd03ff8
|
|
| BLAKE2b-256 |
4e84586c7d3fa6b0d019197c587de59056a675e36ba2917a3a02562ad3be2138
|