Inspired by ongoing conversations in other threads, I’ve started some initial work (very WIP) to implement a general-purpose graph library in Motoko, for a wide variety of possible applications.
If you are interested, I invite you to follow along, post comments or ask questions:
Anticipating several needs, including this graph library, I wrote the start of a sequence library:
It permits efficient split and append operations (O(log n)). This complexity improves on other representations for sequences in Motoko (lists, arrays and buffers) and will be important for workloads that do lots of these operations over large sequences.
Like the Trie module in base, the representation used for these sequences is based on binary trees, is persistent (so no mutation, and no changes to the identity of a sequence once it exists). I have another few steps before the graph library can use this sequence library to maintain its mutable edge sequence, but I am closer now.
This PR is still WIP, but it shows more data modeling example code using this graph library.
This PR also demonstrates ideas from an internal demo app we did from last year (“produce exchange”), to work out the MVP features of the graph library.
(Little did we know how salient a decentralized produce exchange could be in 2020, and beyond.)