Skip to main content

This package provides a simple graph implementation for Python.

Project description

Graph

This package provides a simple graph implementation for Python.



1. Installation

1.1. Using pip

Simply run the usual installation command for pip:

pip install jlvandenhout-graph

1.2. From source

To install from the latest source code, clone this repository and install from the repository:

git clone https://gitlab.com/jlvandenhout/graph.git
cd graph
pip install .

2. Basic usage

from jlvandenhout.graph import Graph

graph = Graph()

names = graph.nodes
transactions = graph.edges

names.add("Alice")
transactions.set("Bob", "Alice", 42)
transactions.set("Alice", "Charlie", 20)

print("\nListing transactions...")
for transaction in transactions:
    sender, receiver = transaction
    print(f"{sender} paid {transaction.get()} to {receiver}.")

print("\nChecking balances...")
for name in names:
    balance = 0
    for transaction in transactions.before(name):
        balance += transaction.get()
    for transaction in transactions.after(name):
        balance -= transaction.get()
    print(f"{name} has {balance}.")

print("\nRemoving Charlie from history...")
names.remove("Charlie")

print("\nListing transactions again...")
for transaction in transactions:
    sender, receiver = transaction
    print(f"{sender} paid {transaction.get()} to {receiver}.")

3. Support

If you have any questions, suggestions or found a bug, please open an issue in the issue tracker.

4. Contributing

Refer to CONTRIBUTING.

5. License

Refer to GNU General Public License v3 (GPLv3).

6. Changelog

Refer to CHANGELOG.

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

jlvandenhout-graph-2.1.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

jlvandenhout_graph-2.1.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file jlvandenhout-graph-2.1.0.tar.gz.

File metadata

  • Download URL: jlvandenhout-graph-2.1.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.4

File hashes

Hashes for jlvandenhout-graph-2.1.0.tar.gz
Algorithm Hash digest
SHA256 1766a416cd234d820ae1c22d4b3cead7d9d3dc925fff9da472fe94a2dc9f4838
MD5 e639082800c2c4f8a20e688c3ade6d76
BLAKE2b-256 efee085e054df3fdbc05676e108b655b57b76b5a15dfa36c5f10303471fec8a2

See more details on using hashes here.

File details

Details for the file jlvandenhout_graph-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: jlvandenhout_graph-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.4

File hashes

Hashes for jlvandenhout_graph-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 11a3ec052213281ea4c7ffcc81ffdc44d8762b0423c258e440274500feebb269
MD5 42b56f92945d09fe3ff8d3e29c2f58e5
BLAKE2b-256 a45c738cc2a8f2ad54dbc95a7e23fd90bf21cd1fa2028326eb65c85159d86ee7

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