Skip to content

danstocker/prime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prime

Prime is a JavaScript graph database designed for one kind of queries: random.

Prime connects string nodes by weighted edges, and offers means to hop from one node to another randomly, guided by the weight distribution of edges, and also a general probability of subsequent jumps.

In the graph below, a hop from fruit would most likely lead to food, then apple, then pear, then the rest at probability decreasing with distance.

Concept Graph

Requires

Examples

  • Learning app: learns associations between words or short expressions.
  • Hop distribution: displays distribution of hop probability depending on node distance.

Usage

Creating a graph

var graph = prime.Graph.create();

Fetching nodes from the graph

Or, creating one on demand.

var $ = graph.getFetcher(),
    node;

node = $('foo');
// or
node = graph.fetchNode('foo');

Building the graph

Quickly connecting nodes that are created on the fly.

var _ = graph.getConnector();

_('food',
    _('fruit',
        'apple',
        'pear'),
    _('turkey'));
_('animal',
    _('bird',
        'turkey'),
    _('feline',
        'cat',
        'lion'));

Modifying the graph

// adds 3 to edge weight between 'food' and 'fruit'
$('food').to($('fruit'), 3);

Hopping

Hopping is a series of semi-random jumps between connected nodes.

var found = $('food').hop().load; // one of all connected nodes

About

Association Engine

Resources

Stars

Watchers

Forks

Packages

No packages published