Skip to main content

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

  1. Get last version:

    $ git clone https://github.com/wxgeo/smallgraphlib
    
  2. Install Poetry.

    Poetry is a tool for dependency management and packaging in Python.

    Installation instructions are here: https://python-poetry.org/docs/#installation

  3. Install developments tools:

    $ poetry install
    
  4. Optionally, update development tools:

    $ poetry update
    
  5. Optionally, install library in editable mode:

    $ pip install -e smallgraphlib
    
  6. Make changes, add tests.

  7. Launch tests:

     $ tox
    
  8. Everything's 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-0.6.1.tar.gz (29.8 kB view details)

Uploaded Source

Built Distribution

smallgraphlib-0.6.1-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: smallgraphlib-0.6.1.tar.gz
  • Upload date:
  • Size: 29.8 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

Hashes for smallgraphlib-0.6.1.tar.gz
Algorithm Hash digest
SHA256 82c937d3f48bc43afa4767cfdc440071d631e862037fb6aadfe00efbcdec7a65
MD5 b25ec69c84577c1d9fe4d11caa647589
BLAKE2b-256 5cbaa42c884107f167f8f7bc4159ab07f12d4668b87a29908cfbb6d896486c91

See more details on using hashes here.

File details

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

File metadata

  • Download URL: smallgraphlib-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 33.2 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

Hashes for smallgraphlib-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8e7738d2651f15fb33bddb86138ad9d5def1ff9d40ba95e834f74acef7a19ddf
MD5 6a20f8857f28e3fc46a6678c9d3685c5
BLAKE2b-256 4d017c2cc16f09d5cfab92aeddf9b6c4fc7fae3f1b8ded1f09d84013b7e8afc9

See more details on using hashes here.

Supported by

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