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.
- Learning app: learns associations between words or short expressions.
- Hop distribution: displays distribution of hop probability depending on node distance.
var graph = prime.Graph.create();
Or, creating one on demand.
var $ = graph.getFetcher(),
node;
node = $('foo');
// or
node = graph.fetchNode('foo');
Quickly connecting nodes that are created on the fly.
var _ = graph.getConnector();
_('food',
_('fruit',
'apple',
'pear'),
_('turkey'));
_('animal',
_('bird',
'turkey'),
_('feline',
'cat',
'lion'));
// adds 3 to edge weight between 'food' and 'fruit'
$('food').to($('fruit'), 3);
Hopping is a series of semi-random jumps between connected nodes.
var found = $('food').hop().load; // one of all connected nodes