# Leafy Graph Library
Leafy is a python graph library written in cython. This mix gives the speed of writing
the library in c with the benefit of python bindings.
## Usage
### Graph Objects
Leafy supports Sparse Graphs, these create Adjacencey lists underneath.
To instantiate a graph object we need to know the number of nodes (verticies) in the
graph, and if the graph is directed. Graphs defualt to undirected.
```python
from leafy import Graph
g = Graph(4, True)
g.add_edge(0, 1)
g.add_edge(2, 3)
g.add_edge(2, 1)
g.list
```
### Search
Leafy can run Depth First Search (DFS) and Breadth First Search (BFS) on a graph and
return the graph search properties.
To run a search we need to define the graph to search and the node to start from.
Before you can view the properties we must call `.run()`.
```python
from leafy.search import DFS
dfs = DFS(g, 0)
dfs.run()
dfs.simple_path(12)
dfs.bridges
```
### Digraphs
For diagraphs leafy supports DFS which can be imported from `leafy.digraph`
```python
from leafy.digraph import DFS
dfs = DFS(g, 0)
dfs.run()
dfs.is_dag
dfs.topological_order()
```
### Shortest Distance
For network shortest path leafy supports single source Dijkstra which can be imported from `leafy.shortest_path`
```python
from leafy.shortest_path import Dijkstra
dij = Dijkstra(g, 0)
dij.run()
dij.path(3)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/ajaaliconsulting/leafy",
"name": "leafy",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "graph dag algorithm library",
"author": "Ahmed Ali",
"author_email": "ahmed@ajaali.com",
"download_url": "",
"platform": null,
"description": "# Leafy Graph Library\nLeafy is a python graph library written in cython. This mix gives the speed of writing\nthe library in c with the benefit of python bindings.\n\n## Usage\n\n### Graph Objects\nLeafy supports Sparse Graphs, these create Adjacencey lists underneath.\n\nTo instantiate a graph object we need to know the number of nodes (verticies) in the\ngraph, and if the graph is directed. Graphs defualt to undirected.\n\n```python\nfrom leafy import Graph\ng = Graph(4, True)\ng.add_edge(0, 1)\ng.add_edge(2, 3)\ng.add_edge(2, 1)\ng.list\n```\n\n### Search\n\nLeafy can run Depth First Search (DFS) and Breadth First Search (BFS) on a graph and\nreturn the graph search properties.\n\nTo run a search we need to define the graph to search and the node to start from.\nBefore you can view the properties we must call `.run()`.\n\n```python\nfrom leafy.search import DFS\ndfs = DFS(g, 0)\ndfs.run()\ndfs.simple_path(12)\ndfs.bridges\n```\n\n### Digraphs\n\nFor diagraphs leafy supports DFS which can be imported from `leafy.digraph`\n\n```python\nfrom leafy.digraph import DFS\ndfs = DFS(g, 0)\ndfs.run()\ndfs.is_dag\ndfs.topological_order()\n```\n\n### Shortest Distance\n\nFor network shortest path leafy supports single source Dijkstra which can be imported from `leafy.shortest_path`\n\n```python\nfrom leafy.shortest_path import Dijkstra\ndij = Dijkstra(g, 0)\ndij.run()\ndij.path(3)\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Another fast graph algorithms library",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/ajaaliconsulting/leafy"
},
"split_keywords": [
"graph",
"dag",
"algorithm",
"library"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8d88612efc203693452a04e5b0139551967e3f53f878e2f5b2fc807393f85bbd",
"md5": "4b5cb66f208a3bf541ec7e4797f7cdcc",
"sha256": "1967e1f019a3ed1d1d107ae31ce957d5cdf8d0264b078ed625643610efaf87e7"
},
"downloads": -1,
"filename": "leafy-1.0.0-cp310-cp310-macosx_11_0_x86_64.whl",
"has_sig": false,
"md5_digest": "4b5cb66f208a3bf541ec7e4797f7cdcc",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.7",
"size": 176014,
"upload_time": "2023-10-04T13:58:31",
"upload_time_iso_8601": "2023-10-04T13:58:31.642905Z",
"url": "https://files.pythonhosted.org/packages/8d/88/612efc203693452a04e5b0139551967e3f53f878e2f5b2fc807393f85bbd/leafy-1.0.0-cp310-cp310-macosx_11_0_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "94778f684282db679f4554b9a12deb7a43e292ba8ffb9387ee4146af0201cf33",
"md5": "368d87b9f44f3d00ca49a4ceb5172766",
"sha256": "8a791dc1abdb3e746c2222b0e2c6ade387b57b56c8ef8a17702d1da9e85b0314"
},
"downloads": -1,
"filename": "leafy-1.0.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "368d87b9f44f3d00ca49a4ceb5172766",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.7",
"size": 957914,
"upload_time": "2023-10-04T13:58:33",
"upload_time_iso_8601": "2023-10-04T13:58:33.317482Z",
"url": "https://files.pythonhosted.org/packages/94/77/8f684282db679f4554b9a12deb7a43e292ba8ffb9387ee4146af0201cf33/leafy-1.0.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e7cd44e0c7a658f9597ef5beca55655e3d146b69cfa6e4671a01e523a1288043",
"md5": "f5cda89130601a981541cc568d227eb6",
"sha256": "34f3bd3b7b5933602cc73179cc055ec63e21ece0c4d01171ca4f518b8aa889d1"
},
"downloads": -1,
"filename": "leafy-1.0.0-cp310-cp310-win_amd64.whl",
"has_sig": false,
"md5_digest": "f5cda89130601a981541cc568d227eb6",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.7",
"size": 163445,
"upload_time": "2023-10-04T13:58:34",
"upload_time_iso_8601": "2023-10-04T13:58:34.408556Z",
"url": "https://files.pythonhosted.org/packages/e7/cd/44e0c7a658f9597ef5beca55655e3d146b69cfa6e4671a01e523a1288043/leafy-1.0.0-cp310-cp310-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "05249bcf80d6b83e9fbd6acce6c4345f6803476817a16092792713954512fecd",
"md5": "289567c78ff0ccd73188bd55c0cf4774",
"sha256": "66c2a1b79b5b0d35372fb17d8f85e6170393fdf2b4311c7e40ecdb1777e9351b"
},
"downloads": -1,
"filename": "leafy-1.0.0-cp311-cp311-macosx_10_9_universal2.whl",
"has_sig": false,
"md5_digest": "289567c78ff0ccd73188bd55c0cf4774",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.7",
"size": 354382,
"upload_time": "2023-10-04T13:58:35",
"upload_time_iso_8601": "2023-10-04T13:58:35.611328Z",
"url": "https://files.pythonhosted.org/packages/05/24/9bcf80d6b83e9fbd6acce6c4345f6803476817a16092792713954512fecd/leafy-1.0.0-cp311-cp311-macosx_10_9_universal2.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b48dfa52381e1f5285189d73db9bd0e6a93a4be60616b1094ad351ed54b83412",
"md5": "d5c240bf70ba07f2aa516c1e7d62a7ee",
"sha256": "a0b8ce228d00f8ce7f410a82ba620dbf721cf94e963de63b567f3fa9dbb3653b"
},
"downloads": -1,
"filename": "leafy-1.0.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "d5c240bf70ba07f2aa516c1e7d62a7ee",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.7",
"size": 1033296,
"upload_time": "2023-10-04T13:58:37",
"upload_time_iso_8601": "2023-10-04T13:58:37.298401Z",
"url": "https://files.pythonhosted.org/packages/b4/8d/fa52381e1f5285189d73db9bd0e6a93a4be60616b1094ad351ed54b83412/leafy-1.0.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "96779009169b63cf6f18f9a9f21a02f0f76e90124f6afd08f0c99a15ce1a1661",
"md5": "02767f20f2e8516c761358b5ea82bf61",
"sha256": "d1a67c8ecfdf06a0d72dfc8a35eb5451435dea9ba439989f1413b883a4c93d06"
},
"downloads": -1,
"filename": "leafy-1.0.0-cp311-cp311-win_amd64.whl",
"has_sig": false,
"md5_digest": "02767f20f2e8516c761358b5ea82bf61",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.7",
"size": 164055,
"upload_time": "2023-10-04T13:58:38",
"upload_time_iso_8601": "2023-10-04T13:58:38.641746Z",
"url": "https://files.pythonhosted.org/packages/96/77/9009169b63cf6f18f9a9f21a02f0f76e90124f6afd08f0c99a15ce1a1661/leafy-1.0.0-cp311-cp311-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b185613fe44acea55f3cec5c53cfc4518901d2fe23d1afd0324fef12f901f69d",
"md5": "6256698b0a9165fad0314de383058367",
"sha256": "8e7c901e14355a2e9a7298c2a83c23cec2accd719b8e85be7b90080178b51d48"
},
"downloads": -1,
"filename": "leafy-1.0.0-cp37-cp37m-macosx_11_0_x86_64.whl",
"has_sig": false,
"md5_digest": "6256698b0a9165fad0314de383058367",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": ">=3.7",
"size": 180105,
"upload_time": "2023-10-04T13:58:40",
"upload_time_iso_8601": "2023-10-04T13:58:40.282612Z",
"url": "https://files.pythonhosted.org/packages/b1/85/613fe44acea55f3cec5c53cfc4518901d2fe23d1afd0324fef12f901f69d/leafy-1.0.0-cp37-cp37m-macosx_11_0_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7be455d82e97d44ad50f0b45a6d1713f4eb2ba3e225c10149f66d6a9e5f4c302",
"md5": "929de67670cfe80c5064204ff846d18b",
"sha256": "5763999916687da14f430d2fd4375f0135b1c812b1191f08528765d8551bedac"
},
"downloads": -1,
"filename": "leafy-1.0.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "929de67670cfe80c5064204ff846d18b",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": ">=3.7",
"size": 893418,
"upload_time": "2023-10-04T13:58:41",
"upload_time_iso_8601": "2023-10-04T13:58:41.462584Z",
"url": "https://files.pythonhosted.org/packages/7b/e4/55d82e97d44ad50f0b45a6d1713f4eb2ba3e225c10149f66d6a9e5f4c302/leafy-1.0.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5a096418af08eaa0fa170674981b9a697b7144a9674c6222a6ab9c0174c69587",
"md5": "31c4cebf61780efe9e0b261d4278f5d6",
"sha256": "61d10c7f26b2d7b9a09c3719e2bc96da675a3c502aeb0e27903cccd0fe2d5d6d"
},
"downloads": -1,
"filename": "leafy-1.0.0-cp37-cp37m-win_amd64.whl",
"has_sig": false,
"md5_digest": "31c4cebf61780efe9e0b261d4278f5d6",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": ">=3.7",
"size": 196239,
"upload_time": "2023-10-04T13:58:42",
"upload_time_iso_8601": "2023-10-04T13:58:42.662590Z",
"url": "https://files.pythonhosted.org/packages/5a/09/6418af08eaa0fa170674981b9a697b7144a9674c6222a6ab9c0174c69587/leafy-1.0.0-cp37-cp37m-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a9f3c3b1a6c9ccd2c6f876d1bd5a1587352d6387a3f52a7d11bfa909fdcb6d58",
"md5": "c98d54f305e84031afefd30083830ff2",
"sha256": "afd8776d8c24a3d3c2d6982d5d1a290137f63e06aa7d3abbb8a061a87b914d97"
},
"downloads": -1,
"filename": "leafy-1.0.0-cp38-cp38-macosx_11_0_x86_64.whl",
"has_sig": false,
"md5_digest": "c98d54f305e84031afefd30083830ff2",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.7",
"size": 180539,
"upload_time": "2023-10-04T13:58:44",
"upload_time_iso_8601": "2023-10-04T13:58:44.454627Z",
"url": "https://files.pythonhosted.org/packages/a9/f3/c3b1a6c9ccd2c6f876d1bd5a1587352d6387a3f52a7d11bfa909fdcb6d58/leafy-1.0.0-cp38-cp38-macosx_11_0_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "de06a3276c07819fffc849b6c0ffc3224d02d20cd1207259fcab5fde134ca121",
"md5": "1b26d5ea97a7583715fd7b6b62453b58",
"sha256": "8d10803b3bb19aa4ae37620aefe04e039c759b2d405944a87edce11458728468"
},
"downloads": -1,
"filename": "leafy-1.0.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "1b26d5ea97a7583715fd7b6b62453b58",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.7",
"size": 965621,
"upload_time": "2023-10-04T13:58:45",
"upload_time_iso_8601": "2023-10-04T13:58:45.665811Z",
"url": "https://files.pythonhosted.org/packages/de/06/a3276c07819fffc849b6c0ffc3224d02d20cd1207259fcab5fde134ca121/leafy-1.0.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "32416abc2ab2a2049f08e2a85d58c929cad7b3e0a8c7a7e394d33cd43eb7a350",
"md5": "ba1bdbc5c23c1c3b8b5ba7f20047b214",
"sha256": "d13debef0a074713efb7ab380dba69ecd0ab0a6e59db2573ad6a8f514064abf2"
},
"downloads": -1,
"filename": "leafy-1.0.0-cp38-cp38-win_amd64.whl",
"has_sig": false,
"md5_digest": "ba1bdbc5c23c1c3b8b5ba7f20047b214",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.7",
"size": 195898,
"upload_time": "2023-10-04T13:58:46",
"upload_time_iso_8601": "2023-10-04T13:58:46.855890Z",
"url": "https://files.pythonhosted.org/packages/32/41/6abc2ab2a2049f08e2a85d58c929cad7b3e0a8c7a7e394d33cd43eb7a350/leafy-1.0.0-cp38-cp38-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "314446e5068efd4c2ad965028741d634f2fe058363beacd1ce299eecad2d1a83",
"md5": "3f6ee32676390c3f5f6392eaf59b4d25",
"sha256": "692c45d53616a069468c2d21ff199bad9d29d92b23d4a6e46fb2c24e4267d4e9"
},
"downloads": -1,
"filename": "leafy-1.0.0-cp39-cp39-macosx_11_0_x86_64.whl",
"has_sig": false,
"md5_digest": "3f6ee32676390c3f5f6392eaf59b4d25",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.7",
"size": 178812,
"upload_time": "2023-10-04T13:58:48",
"upload_time_iso_8601": "2023-10-04T13:58:48.415575Z",
"url": "https://files.pythonhosted.org/packages/31/44/46e5068efd4c2ad965028741d634f2fe058363beacd1ce299eecad2d1a83/leafy-1.0.0-cp39-cp39-macosx_11_0_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e00b3d47549e80beb4a899dabb1ed0c12d824d6ba6cb08cf7e7080eb44b015af",
"md5": "b6c3db22fa619cf101b43d82a44c5150",
"sha256": "d60f723a87b88ece7c9de85085fe571569afec77e54781ddbb6279ac6eb9af86"
},
"downloads": -1,
"filename": "leafy-1.0.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "b6c3db22fa619cf101b43d82a44c5150",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.7",
"size": 973680,
"upload_time": "2023-10-04T13:58:50",
"upload_time_iso_8601": "2023-10-04T13:58:50.082303Z",
"url": "https://files.pythonhosted.org/packages/e0/0b/3d47549e80beb4a899dabb1ed0c12d824d6ba6cb08cf7e7080eb44b015af/leafy-1.0.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b7a859ad7be4a2e4a97c75f395720f0f9a0df6912fd574cfb8983ade8f09a31b",
"md5": "f9515dfefba7aa57d6330627d43a4c12",
"sha256": "72facfd2b769c93ba6c04287961433411ed6bb4b9ba3e09bf476c73f84926f7b"
},
"downloads": -1,
"filename": "leafy-1.0.0-cp39-cp39-win_amd64.whl",
"has_sig": false,
"md5_digest": "f9515dfefba7aa57d6330627d43a4c12",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.7",
"size": 195860,
"upload_time": "2023-10-04T13:58:51",
"upload_time_iso_8601": "2023-10-04T13:58:51.163094Z",
"url": "https://files.pythonhosted.org/packages/b7/a8/59ad7be4a2e4a97c75f395720f0f9a0df6912fd574cfb8983ade8f09a31b/leafy-1.0.0-cp39-cp39-win_amd64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-04 13:58:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ajaaliconsulting",
"github_project": "leafy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"test_requirements": [],
"lcname": "leafy"
}