Skip to main content

Another fast graph algorithms library

Project description

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.

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().

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

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

from leafy.shortest_path import Dijkstra
dij = Dijkstra(g, 0)
dij.run()
dij.path(3)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

leafy-1.0.0-cp311-cp311-win_amd64.whl (164.1 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

leafy-1.0.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl (1.0 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.28+ x86-64 manylinux: glibc 2.5+ x86-64

leafy-1.0.0-cp311-cp311-macosx_10_9_universal2.whl (354.4 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64)

leafy-1.0.0-cp310-cp310-win_amd64.whl (163.4 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

leafy-1.0.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl (957.9 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64 manylinux: glibc 2.5+ x86-64

leafy-1.0.0-cp310-cp310-macosx_11_0_x86_64.whl (176.0 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ x86-64

leafy-1.0.0-cp39-cp39-win_amd64.whl (195.9 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

leafy-1.0.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl (973.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64 manylinux: glibc 2.5+ x86-64

leafy-1.0.0-cp39-cp39-macosx_11_0_x86_64.whl (178.8 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ x86-64

leafy-1.0.0-cp38-cp38-win_amd64.whl (195.9 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

leafy-1.0.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl (965.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.28+ x86-64 manylinux: glibc 2.5+ x86-64

leafy-1.0.0-cp38-cp38-macosx_11_0_x86_64.whl (180.5 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ x86-64

leafy-1.0.0-cp37-cp37m-win_amd64.whl (196.2 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

leafy-1.0.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl (893.4 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.28+ x86-64 manylinux: glibc 2.5+ x86-64

leafy-1.0.0-cp37-cp37m-macosx_11_0_x86_64.whl (180.1 kB view hashes)

Uploaded CPython 3.7m macOS 11.0+ x86-64

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