@nelson-ai/graph-traversal

1.0.1 • Public • Published

Edge Factory Graph Traversal library

This is a graph traversal library, loosely inspired from Gremlin.

Main differences with Gremlin

  • Gremlin uses a property graph, where edges may have properties. Since Edge Factory is in JSON-LD (aka RDF), edges are predicates and cannot embed attributes.

  • In the Edge Factory graph, type is mandatory. We leverage this by auto-indexing on types.

Playing

We provide a REPL to play with the edge-graph. You can start it by running npm run repl.

You can then start playing with the API. For example, to

Examples

  • fetch all classes that inherit edgeo:Thing
> g.v('edgeo:Thing').in('subClassOf').get('id')
  • get the id and label of Asset instances
> g.t('Asset').get('id', 'label')
  • get the levers, count them, add some conditions
> g.t('Lever').count()
> g.t('Lever').has('timeHorizon', 12).count()
> g.v('edger:process1').out('levers').get('id', 'timeHorizon')
> g.v('edger:process1').out('levers').count()
> g.v('edger:process1').out('levers').has('timeHorizon', 12).count()
> g.v('edger:process1').out('levers').has('timeHorizon', 12).get('id', 'timeHorizon')

API

TODO: list all API methods

Gotchas :

g.v

  • id => return a Vertex
  • array of id => return a VertexList

VertexList.filter

The data received by a filter function is a Vertex, not a POJO. Use get() to access data fields...

const r = g.v('test:edge')
           .in('worksFor')
           .filter(p => p.get().age < 30)
           .get('id', 'age');

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    1
  • 1.0.0
    0
  • 0.0.1
    0

Package Sidebar

Install

npm i @nelson-ai/graph-traversal

Weekly Downloads

1

Version

1.0.1

License

SEE LICENSE IN LICENSE

Last publish

Collaborators

  • cornik
  • dherault
  • eric.abouaf