specter

Latest version: 1.1.3
npetryk 2018-10-31T14:18:57.016500Z

Hey @nathanmarz, in a few of your blog posts you mention using specter for some pretty interesting graph stuff. I was interested in making specialized navigators for https://jsonapi.org/ and thought some examples of defining navigators for "specialized" domains might be helpful. Do you have any more information / examples about your graph implementation?

npetryk 2018-10-31T14:20:13.017700Z

IDK if ur familiar with the spec but the most kludgey thing it requires me to do is to hold onto the top level document, or some kind of id -> entity index, while I'm navigating through the tree structure w/ specter

npetryk 2018-10-31T14:21:47.018700Z

I'm handling that by attaching metadata onto the things I'm navigating into, but like I said, its a little kludgy

nathanmarz 2018-10-31T14:34:55.019100Z

@npetryk my graph navigators are specifically for dag's

nathanmarz 2018-10-31T14:35:11.019500Z

TOPSORT is like ALL but visits nodes in topological order

nathanmarz 2018-10-31T14:35:46.020Z

REVERSE-TOPSORT is the same but opposite order

nathanmarz 2018-10-31T14:35:59.020300Z

CHILDREN goes from node to all children

nathanmarz 2018-10-31T14:36:07.020600Z

likewise PARENTS, DESCENDANTS

nathanmarz 2018-10-31T14:36:31.021Z

NODE goes from a pointer to a node (which the aforementioned ones navigate you to) to the value for that node

nathanmarz 2018-10-31T14:36:56.021300Z

node-nav navigates to a specific node

nathanmarz 2018-10-31T14:37:58.022100Z

and then a couple navigators for navigating to sub-dag's, with metadata and ids on nodes used to determine how to attach the transformed sub-dag into the parent dag

nathanmarz 2018-10-31T14:38:49.022500Z

there's a few more but those are the main ones

nathanmarz 2018-10-31T14:40:30.023100Z

for navigating a tree you probably don't need custom navigator implementations, just a few composite navigators using recursive-path

nathanmarz 2018-10-31T14:40:35.023300Z

if you have some examples I can walk you through it

npetryk 2018-10-31T15:10:12.025Z

Thanks! https://github.com/nathanmarz/specter/issues/241 also gave me some insight. It looks like that instead of passing [graph node-id] around I can just pass my tree "context" as metadata on individual nodes. The bit about reducing in the transform is also helpful for when I need to make updates to my tree