aysylu / loom

Graph library for Clojure. Mailing list https://groups.google.com/forum/#!forum/loom-clj
http://aysy.lu/loom/
886 stars 108 forks source link

How does the ancestry cache work? #130

Open lunik1 opened 3 years ago

lunik1 commented 3 years ago

I am having trouble understanding how to use the ancestry cache, and the docs are not very clear. I assume it must be populated using ancestry-add however doing this the obvious way results in an error:

(ancestry-add (ancestry-new) :child1 :parent1 :parent2)
Execution error (IllegalArgumentException) at loom.alg-generic/ancestry-add (alg_generic.cljc:558).
Key must be integer

ancestry-add only seems to work if the parent nodes already exist in the cache, but then the cache does not properly reflect the hierarchy:

(ancestor? (ancestry-add (ancestry-add (ancestry-add (ancestry-new) :child) :parent) :child :parent) :child :parent)
false