Roll your own graph database for Emacs

Viewed 207

I'm contemplating an Emacs app that would offer basic graph database capabilities to org-mode. I'd like to write the code myself, a roll your own graph data app. Can anyone direct me to data structures, algorithms for such an undertaking? I know little about graph theory, just the basics. For my endeavor I'd like to store both the org-mode headings inside a single org-mode file as vertices, but also have the option to store a whole org-mode file as single vertex. Each file, each heading vertex will have a unique UUID number in an org-mode PROPERTIES "drawer," which can be understood as a struct for each heading. Edges might be RFD-ish -- essentially "predicate" vertices used as edges. Making a wild guess, I'd say graphs are stored as adjacency lists and not adjacency matrices? Some form of querying should be possible as well.

Any advice appreciated.

2 Answers

So, when I do something like that in org-mode I frequently fall back to its native graphviz support.


# Toggle inline images: c-c c-x c-v
#+BEGIN_SRC dot :results output :file outfilename.png

   digraph "graphname" {

          A [label="foo"];
          B [label="bar", shape="box"];
          C [label="baz", shape="box"];

          A -> B;
          A -> C;
          C -> B;
          
   }

#+END_SRC

#+RESULTS:
[[file:outfilename.png]]

If you need a lot of data, it's not hard to convert a CSV file to a set of graphviz points.

I'd say this is a good starting point for me. A good discussion. One poster mentioned the very brilliant The Algorithm Design Manual by Steven S. Skiena.

Related