##MicroDB Graph Database The MicroDB Graph Database is a graph database written in python. A graph database embodies the properties of a graph, consisting entirely of nodes and edges (relationships). Each node and relationship in the database is defined by its attributes. A user can query the database to find useful information about the graph, such as connections between nodes, shortest path to a particular node, and other interesting statistics.
##Usage
The database can be started by typing in
python start.py
This will load any graph database files from disk to restore the graph state, if one existed.
Commands can be entered at the prompt ">>>".
Commands are terminated by a space followed by a semicolon. For example:
>>> Create n: a asdf:12;
Here are some examples of usage (Look at testfile.txt for more examples):
>>> create n: a b:c;
Unique node id: 1
Nodes
[(1, {'b': 'c'})]
Edges
[]
Identifier
{'a': (1, {'b': 'c'})}
>>> return n: a;
a = (1, {'b': 'c'})
Unique node id: 1
Nodes
[(1, {'b': 'c'})]
Edges
[]
Identifier
{'a': (1, {'b': 'c'})}
>>>
##Query Language
The query language takes the form:
CREATE ID ATTR ...
CREATEEDGE ID ATTR REL ATTR ID ATTR
MATCH ID ATTR (PRED) REL ATTR ID ATTR (PRED) REL ATTR ID ATTR ...
MODIFYNODE ID ATTR ID ATTR BOOL
MODIFYEDGE REL ATTR REL ATTR BOOL
DELETENODE ID ATTR
DELETEEDGE REL ATTR
RETURN ID ID ...
HASPATH ID ATTR ID ATTR
SHORTESTPATH ID ATTR ID ATTR
NEIGHBOR ID ATTR
HASEDGE ID ATTR ID ATTR
SHOW
CLEAR
VISUALIZE
REL ATTR = e: a b:c
ID ATTR = n: a a:b
BOOL = b: a val:0/1 - 1 means add the attribute, and 0 means delete the attribute
ID = n: a
PRED = a(pred)b
##Framework
The database is started by initializing the StartDatabase class. This loads the graph files from disk and starts the prompt to take input from the user.
The parser is then called (from parser.py) and parses commands from the user, passing in the objects parsed into the linker (from linker.py). The linker then calls the appropriate evaluation methods in query_evaluator.py.
##Libraries Libraries needed for this database are:
NetworkX
matplotlib
pprint
##Testing Testing is currently only available for the query_evaluator.py methods. The python unittest library is used for testing. Tests for the query_evaluator methods can be run by
python test_query_evaluator.py
##Documentation
The documentation files can be generated by
epydoc --config=doc_config.txt
The files are then generated into the pythondoc folder (open index.html to view the documentation)