0.5.0 • Published 4 years ago

@seneca/graph v0.5.0

Weekly downloads
37
License
MIT
Repository
github
Last release
4 years ago

seneca-graph

Npm Travis Coveralls

A Seneca plugin that provides basic graph operations.

Install

$ npm install seneca-graph

Action Patterns

Action Descriptions

« add:rel,role:graph »

Add a directed relation between two nodes in a given graph.

Examples

  • add:rel,role:graph,graph:number,rel:lessthan,add:rel,from:<from-id>,to:<to-id>
    • Idempotently add a pair of nodes to number graph connected by directed relation lessthan with from-id and to-id referencing external entity identifiers as per graph definition in options.

Parameters

Replies With

{
  from: '_from_ parameter, as provided',
  to: '_to_ parameter, as provided',
  rel: '_rel_ parameter, as provided',
  graph: '_graph_ parameter, as provided',
  node: {
    f: 'from-side entity identifier',
    t: 'to-side entity identifier',
    r: 'relation name',
    id: 'internal graph node identifier'
  }
}

« list:rel,role:graph »

List nodes connected by a given relation.

Examples

  • list:rel,role:graph,graph:number,rel:lessthan,list:rel

    • List all nodes in number graph connected by directed relation lessthan
  • list:rel,role:graph,graph:number,rel:lessthan,list:rel,from:<from-id>

    • List all nodes in number graph connected by directed relation lessthan with given from-id
  • list:rel,role:graph,graph:number,rel:lessthan,list:rel,to:<to-id>

    • List all nodes in number graph connected by directed relation lessthan with given to-id
  • list:rel,role:graph,graph:number,rel:lessthan,list:rel,to:<to-id>,entity:from

    • List all nodes in number graph connected by directed relation lessthan with given to-id, loading and including referenced from-side entities
  • list:rel,role:graph,graph:number,rel:lessthan,list:rel,entity:to

    • List all nodes in number graph connected by directed relation lessthan, loading and including referenced to-side entities

Parameters

Replies With

{
  from: '_from_ parameter, as provided',
  to: '_to_ parameter, as provided',
  rel: '_rel_ parameter, as provided',
  graph: '_graph_ parameter, as provided',
  list: [
    {
      f: 'from-side entity identifier',
      t: 'to-side entity identifier',
      r: 'relation name',
      id: 'internal graph node identifier',
      fe: 'from-side entity',
      te: 'to-side entity'
    },
    '...'
  ]
}

« role:graph,tree:rel »

Load tree of nodes connected by given relation.

Examples

  • role:graph,tree:rel,graph:number,rel:lessthan,from:<from-id>

    • Load tree of nodes from number graph connected by directed relation lessthan with from-id nodes at first level, to default depth of 1.
  • role:graph,tree:rel,graph:number,rel:lessthan,from:<from-id>,depth:2,entity:to

    • Load tree of nodes from number graph connected by directed relation lessthan with from-id nodes at first level, to depth 2, loading and returning referenced to-side entities.

Parameters

Replies With

{
  from: '_from_ parameter, as provided',
  to: '_to_ parameter, as provided',
  rel: '_rel_ parameter, as provided',
  graph: '_graph_ parameter, as provided',
  c: [
    {
      f: 'from-side entity identifier',
      t: 'to-side entity identifier',
      r: 'relation name',
      id: 'internal graph node identifier',
      fe: 'from-side entity',
      te: 'to-side entity',
      c: [
        '{ ...connected-nodes... }'
      ]
    },
    '...connected-nodes...'
  ]
}

0.5.0

4 years ago

0.4.2

5 years ago

0.4.0

5 years ago

0.2.1

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago