Skip to main content

Simple library for handling small graphs, including Tikz code generation.

Project description

Small Graph Lib

Installing

Basic installation

Smallgraphlib is on PyPI, so you can download and install it with pip, as any usual python package.

pip install smallgraphlib

Development version

For development, please clone the last version from Github:

git clone https://github.com/wxgeo/smallgraphlib

You 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 | sh

More information on uv installation

It is also recommended to install just command runner, to execute the recipes of the justfile.

uv tool install rust-just

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

  1. Get development version and uv

  2. Install dependencies including development tools:

uv sync
  1. Optionally, update dependencies and development tools:
uv sync --upgrade
  1. Optionally, install library in editable mode:
uv pip install -e smallgraphlib
  1. Make changes, add tests.

  2. Launch tests:

just test
  1. Everything OK? Commit. :)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smallgraphlib-1.3.0.tar.gz (43.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smallgraphlib-1.3.0-py3-none-any.whl (51.1 kB view details)

Uploaded Python 3

File details

Details for the file smallgraphlib-1.3.0.tar.gz.

File metadata

  • Download URL: smallgraphlib-1.3.0.tar.gz
  • Upload date:
  • Size: 43.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for smallgraphlib-1.3.0.tar.gz
Algorithm Hash digest
SHA256 8ad05d19d4f9c0a0799c97f2f74d74e989d405cacf225d0c4a7a088edaf78bde
MD5 f70d2d64843943a12e96a7ea1de3c437
BLAKE2b-256 f8619903971eb27badd56a6540bd9e49ae559c01367401a7878da4ca7d240c03

See more details on using hashes here.

File details

Details for the file smallgraphlib-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: smallgraphlib-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 51.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for smallgraphlib-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e346bd2c483c5a9e5842db7242e1879077c55d71f61f992db6612b7afc77d3e
MD5 6ac636a153498a2e9526bfc225ab46cd
BLAKE2b-256 af5c8228213819eb79f88aa567ed2f8123b08b4a8f4855f0bd5e22b6cccbeb1d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page