A graph theory library written in Cython
Project description
cygraph
A graph theory library implemented in Cython
Installation
pip install cygraph
Usage
Python
Here is an example Python script that utilizes some of the features of cygraph.
import cygraph as cg
import cygraph.algorithms as alg
G = cg.graph(vertices=list(range(4)))
G.add_edge(1, 2)
G.add_edge(2, 3)
G.add_edge(3, 1)
children = G.get_children(1)
print(f'{children=}')
components = alg.get_number_components(G)
print(f'{components=}')
It should output:
children={2, 3}
components=2
Cython
Here is the above script but with static typing in Cython.
#!python
#cython: language_level=3
import cygraph as cg # cg.graph function.
cimport cygraph.graph_ as gp # StaticGraph and DynamicGraph types.
cimport cygraph.algorithms as alg
cdef gp.DynamicGraph G = cg.graph(vertices=list(range(4)))
G.add_edge(1, 2)
G.add_edge(2, 3)
G.add_edge(3, 1)
cdef set children = G.get_children(1)
print(f'children={str(children)}')
cdef int components = alg.get_number_components(G)
print(f'components={components}')
For more information on the Python and Cython APIs, see the documentation
Contribution
I am currently not accepting any pull requests. This project is still in its very early stages and I have many things in mind to do with it. Once I get those things done, I will add contribution guidelines.
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.
Source Distribution
cygraph-0.1.6.tar.gz
(694.4 kB
view hashes)
Built Distribution
Close
Hashes for cygraph-0.1.6-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf3597bc939320802c3feaed1dc605a0bf7fa45fd32d590f95fb1d42c22b7af5 |
|
MD5 | 6f8b59ce39ee673ca558a6e1115f18dc |
|
BLAKE2b-256 | dd1e10c27ba0e8d9dab4974853fba5d0865a2dfaed6fab945f325d0bcb827c52 |