node - defines a node/vertex in your graph.
edge - defines the relationship between nodes.
walker - creates a robot that traverses the graph performing various user defined actions.
spawn - used to create/instantiate a node.
has - used to define properties of
nodesandwalkers.
can - actions a node can perform.
anchor - keyword used to annotate a single
propertyof a node that can be used as the return value of said node.
with entry - block of actions to be taken when a
walkeris initialised and before it begins traversal
take - Queues up edge traversal that is executed in a sequential order.
here - context of the current node the
walkeris on.
Here,
personis the type given to this node.
node person {
}
node person{
has firstName, lastName, dob
}
Actions can be thought of as functions, and needs to be defined before hand. Jac has a few built in actions that can be found at
jaseci>core>actions
node person{
has firstName, lastName, dob;
can actions.sing_song, action.make_friends, actions.dance
}
Edges can be thought of as the relationship between two nodes. A
person nodecan have afriendrelationship with anotherperson node. From my understanding, edges don't yet supportproperties. This is in the works though.
edge friend;
edge sibling;
walker find_friends{
}
In Jac, you are able to spawn typed or generic nodes.
node1is an example of a generic node andnode2is a node of the person type.
walker init{
node1 = spawn node;
node2 = spawn node::person;
}
walker init{
node1 = spawn node::person;
node2 = spawn node::person;
node3 = spawn node::person;
node1 <-> node2
node2 --> node3
node2 --> here
here --> node1
}
walker init{
node1 = spawn node::person;
node2 = spawn node::person;
node3 = spawn node::person;
node1 <-[friend]-> node2
node2 -[family]-> node3
node2 --> here
here --> node1
}
Assume we have defined two types of nodes
personandpet. Any code in block cointaining...1will always be executed for that walker, no matter which node it is on. Any code in...2will only be executed if the walker is on a node ofpersontype and so forth.
walker family_ties{
...1
...1
...1
person{
...2
...2
}
pet{
...3
...3
}
}
