carrot icon indicating copy to clipboard operation
carrot copied to clipboard

Evaluate use of Clojurescript tooling for representing graph-like objects

Open GavinRay97 opened this issue 6 years ago • 1 comments

Lisps are a very unique language. It is one of the only languages that is homoiconic, and this feature, combined with its S-Expressions and macro abilities let you do some pretty neat things with it.

Some data structures and tasks which would be fairly difficult to represent in other languages are trivial in Lisps.

Two tools seem like they could be helpful in this domain:


Ubergraph: https://github.com/Engelberg/ubergraph

Features

  • Ubergraph supports directed edges, undirected edges, weighted edges, node and edge attributes.
  • Ubergraph goes beyond Loom's protocols, allowing a mixture of directed and undirected edges within a single graph, multiple "parallel" edges between a given pair of nodes, multiple weights per edge, and changeable weights.

Ubergraph is a great choice for people who:

  • Don't want to think about which specific graph implementation to use. (Hmmm, do I need directed edges or undirected edges? Do I need weights or attributes for this project? I'm not sure yet, so I'll just use ubergraph because it can do it all.)
  • Need advanced graph capabilities.

Fabric: https://github.com/thi-ng/fabric

Features

  • Sync, async, parallel & continuous processing (and mixtures of)
  • Partial or stepwise execution
  • Activity scoring system (customizable)
  • Automatic graph convergence detection (no more outstanding actions)
  • Computation of minimum active work set
  • Built-in graphs & vertices are mutable (via atoms)
  • Edges are functions and all signal/collect actions are purely functional too
  • Support for graph modification logging (persistence, event sourcing etc.)
  • Self-modifiable graphs during execution (add/remove/modify vertices/edges)
  • Reactive & Distributed programming support

Of the two, it seems like Fabric is much more comprehensive.

With Fabric, it should be possible to do multigraph/mix-cycle graphs arbitrarily, with async/parallel processing, automatic cycle/convergence detection, and easy dynamic network reconfiguration with reactive programming

GavinRay97 avatar Nov 02 '19 20:11 GavinRay97

Just to clarify: At this point in time, I cannot recommend using thi.ng/fabric anymore - it hurts to say it, but it's true. The project has been unmaintained for 3+ years now and much of the ideas and learnings have informed the newer, more powerful/flexible (and actively maintained) thi.ng/rstream packages (TypeScript), even though they're no direct replacement for some of Fabric's features, especially the semantic web/linked data oriented aspects. There's some ongoing development to bring back some of Fabric's triple/fact graph & SPARQL/Datalog inspired query DSL features, but this has been low priority thus far and somewhat of a slow-burner...

With rstream you can build similar dynamic dataflow graph structures (even cyclic ones), but the processing model is more flexible, e.g. via composable transducers and/or various high-level operators to split/merge/synchronize streams, add sidechain controls, fork-join w/ webworkers etc. Work on a visual node editor to construct/edit these graphs has started a while ago, currently paused, but will continue early next year.

Finally, whilst Fabric worked really well in Clojure (JVM), the lack of true multi-threading and the scalability issues of ClojureScript's core.async primitives turned out not be a great fit for using this project efficiently(!) in the browser - at least not with graphs consisting of 1000s of nodes (which is quite easily done)...

I hope this helps - please get in touch (maybe better via Discord) if you've got other questions...

postspectacular avatar Nov 03 '19 01:11 postspectacular