Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aluriak/graffunc
Python 3 data structure -- (hyper)graph of function
https://github.com/aluriak/graffunc
data-structures graph hypergraph python
Last synced: about 1 month ago
JSON representation
Python 3 data structure -- (hyper)graph of function
- Host: GitHub
- URL: https://github.com/aluriak/graffunc
- Owner: Aluriak
- License: gpl-3.0
- Created: 2016-03-11T10:33:13.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-11-08T22:36:12.000Z (about 7 years ago)
- Last Synced: 2024-10-08T00:54:28.040Z (3 months ago)
- Topics: data-structures, graph, hypergraph, python
- Language: Python
- Homepage:
- Size: 57.6 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.mkd
- License: LICENSE
Awesome Lists containing this project
README
# Graffunc -- The graph of function data structure
Python package allowing manipulation of data by graph pathfinding.## usage example
(see more in [tests](graffunc/test/) and [examples](examples/))from graffunc import graffunc, InconvertibleError
def my_a_to_b_converter(a):
b = a.upper()
return {'b': b}
def my_b_to_c_converter(b):
c = 'payload: ' + b + '/payload'
return {'c': c}
def my_a_to_c_converter(a):
raise InconvertibleError()# creation of the main object
grfc = graffunc({
('a',): {('b',): my_a_to_b_converter},
})
# dynamic modification of the object
grfc.add(my_b_to_c_converter, sources={'b'}, targets={'c'})
grfc.add(my_a_to_c_converter, sources={'a'}, targets={'c'})assert {'a', 'b', 'c'} == grfc.reachables_types(sources={'a'})
assert {'b', 'c'} == grfc.reachables_types(sources={'b'})
assert {'c'} == grfc.reachables_types(sources={'c'})assert {'b': 'HELLO'} == grfc.convert(sources={'a': 'hello'}, targets={'b'})
assert {'c': 'payload: HELLO/payload'} == grfc.convert(sources={'a': 'hello'}, targets={'c'})## installation
pip install graffunc
## links
[github](http://github.com/aluriak/graffunc) and [pypi](http://pypi.python.org/pypi/graffunc)