Mogwai represents graphs using a line based syntax. Each line is either a node or an edge. Comments start with #
.
Nodes
Nodes are defined with an identifier and a label. Optional properties can follow in parentheses.
alice:Person
book:Book(title="1984", year=1949)
- Identifier – unique name for the node
- Label – type or category of the node
- Properties – comma separated
key=value
pairs
Edges
Edges connect two nodes with a relationship label. Use one dash for solid lines or two dashes for dotted lines.
alice-friends->bob
alice--seen-->movie(rating=5)
The general pattern is <from>-<rel>-><to>
. Use --
on both sides of the relation to create a dotted edge.
Complete example
alice:Person(name="Alice")
bob:Person(name="Bob")
movie:Movie(title="Inception")
alice-friends->bob
alice--watched-->movie(date="2010-07-16")
Try it out
Experiment with Mogwai in the interactive editor.
Comments
Add comments anywhere on a line after
#
. The parser ignores everything after the hash.