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
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.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size jlvandenhout_graph-1.1.0-py3-none-any.whl (16.5 kB) | File type Wheel | Python version py3 | Upload date | Hashes View |
Filename, size jlvandenhout-graph-1.1.0.tar.gz (3.5 kB) | File type Source | Python version None | Upload date | Hashes View |
Close
Hashes for jlvandenhout_graph-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5f77c6198b829bb411eaed000130fa4d1b6e6fe50b54abc395cb90181761732 |
|
MD5 | 8e5cb2072558aa25dd72e3e5efd8352f |
|
BLAKE2-256 | 6dd16528947eb6665a9cf7787cdacf50aaecd5a4ca3864c53e58fb3ea903ae6d |