-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement in-memory graph store #68
Comments
Making good progress on this one. Here's some usage I've been testing tonight ... Load data from files: (set `#(ok ,rm1) (mudgraph-v1:load "rooms" "room1"))
(set `#(ok ,rm2) (mudgraph-v1:load "rooms" "room2"))
(set `#(ok ,obj1) (mudgraph-v1:load "objects" "sword"))
(set `#(ok ,obj2) (mudgraph-v1:load "objects" "painting"))
(set `#(ok ,per1) (mudgraph-v1:load "characters" "eve")) Convert these to maps for use as "labels" (arbitrary data storage) on the nodes: (set rm1 (proplists:to_map rm1))
(set rm2 (proplists:to_map rm2))
(set obj1 (proplists:to_map obj1))
(set obj2 (proplists:to_map obj2))
(set per1 (proplists:to_map per1)) Now actually use the graph DB :-) (set v1 (mg:add-vertex rm1)) ; we'll store the vertex's ID in a variable so we can look it up latter
(mg:add-vertex rm2)
(set e1 (mg:add-edge rm1 rm2 #m(type transit direction east size normal))) ; again, for later look-up
(mg:add-edge rm2 rm1 #m(type transit direction west size normal))
(mg:add-vertex obj1)
(mg:add-vertex obj2)
(mg:add-vertex per1)
(mg:add-edge obj1 rm1 #m(type contains))
(mg:add-edge obj2 rm1 #m(type contains))
(mg:add-edge per1 rm1 #m(type contains))
(mg:in-edges rm1)
(mg:in-neighbours rm1)
(mg:out-neighbours rm1)
(mg:in-neighbours rm1 'contains) ; get all objects in the room
(mg:out-neighbours rm1 'transit) ; get all exits out of the room
(mg:vertex v1)
(mg:edge e1) I don't have a good, general solution for filtering edges (and thus neighbours) on all possible k/vs in a map ... only filtering by one ( |
There are more Erlang digraph funcs to wrap; I'll do that as I need them. |
More thoughts about data modelling:
|
Part of:
Tasks:
The text was updated successfully, but these errors were encountered: