Roll your own graph database for Emacs - emacs

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.

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

Inner workings of Google's Quick Draw

I'm asking this here because I didn't find anything online.
I would be interested in how Google Quick Draw works, specifically:
1) How does it output the answer - does it have a giant output vector with a probability for each type of drawing?
2) How does it read the data - I see they've implemented some sort of order aware input system, but does that mean that they input positions of the interpolated lines that users draw? This is problematic because it's variable length - how did they solve it?
3) And, finally, which training algorithm are they using? The data grows each time someone draws something new, or do they just feed it into the algorithm when it's created?
If you know any papers on this or by miracle you work at Google and/or can explain how it works, I would be really greatful. :)

Transpose Coordinates to UTM84-17N Projection

In Swift, is there a way to input Lat/Long coordinates from MapKit, and translate those coordinates to a specified Projection, such as UTM84-17N (e.g. AutoCAD format)?
Well, I never did figure out how to do this using iOS/Swift, but I did discover a lisp code in both AutoCAD Map (two or three lines of code) and even better, in BricsCAD using the Spatial Manager extension (One single line of code).
For both, they involve three parameters: the source coordinates (in my case are in lat/long) the source projection code and the destination projection code.
The projection codes lists are provided in 'help.'
Actually, the company who owns Spatial Manager actually wrote the routine to fit into lisp for me when I posed the question to them; amazing!
So, there might be a manageable method that can be written for any platform.., who knows.
If anyone is interested in those lines of code to work in CAD, I'll look them up and post them.
By the way, a plug for BricsCAD: AutoCAD MAP from Autodesk, is now like almost $10,000 Canadian; BricsCAD is far less than $1000 for their best Pro option. NO BRAINER. AND, I find after being a guru in AutoCAD scripting for years, that BricsCAD is way better! AutoCAD is now so full of bloatware trinkets and useless stuff (similar to Windows' verification window pop ups) that it takes about 30 seconds just to load on a fast rig. And they have made things so much more difficult for old school users. Not to mention, the folks at BricsCAD are so incredibly helpful you feel like family with them!
...only one tiny flaw so far in going with them tho. They don't have a proper lisp editor (that I can find anyway), that lets you test the code line by line real time - like AutoCAD does...

Generating txt file in complex format from Matlab datas

I'm relatively new to Matlab and currently using it to calculate pressure cards for rapid dynamic applications on RADIOSS.
The function is done and can calculate Time-Pressure points.
For the moment I generated only .ascii files to import as curves into the software but I'd like to directly write a text file readable by RADIOSS. (after conversion)
The formatting I need is very specific and I'd like to know if such a thing is possible to do on Matlab. I've been searching on my own for some time now and didn't find really specific formatting options so I come seeking for your advice.
For example I have n time Arrays Te{1 to n} an n Pressure Arrays Pr{1 to n} the format needed is presented in the image linked. How can it be done if it is possible ?
The sprintf function is quite powerful and should provide all the facilities you need. Having looked at the image you linked, I don't see anything particularly special.

Matlab: Write text to PDF

I'd like to create a PDF out of my matlab m-function. The PDF should contain some text information which I want to style a bit and one image (which is previously generated as figure). Is there any way? The only thing I found is publish to publish source-code. The only alternative I could think off was to programm the texts into the figure window and than export the whole figure to pdf. Perhaps there's a better way to do it?
Thanks!
I would recommend generating your figure with Matlab, outputting it to eps, then converting the figure to pdf using epstopdf. Then embed your figure in a latex document and generate a pdf with pdflatex.
I know this sounds like an incredibly roundabout way of doing it, but
This is the way I've come to do it after years of experience and it always gives me the best results
Every one of my colleagues does it this way for the same reason
The results will be completely reproducible
You're using Matlab to do what it's good at (making scientific figures) and latex to do what it's good at (formatting documents)
The Matlab code to make the eps of the figure would be like this (supposing your figure is figure 1):
print -depsc2 -f1 -loose my_fig.eps
You could pretty easily write a latex template that uses my_fig.pdf and then run everything from your Matlab using bangouts:
!epstopdf my_fig
!pdflatex mydoc.tex
If you're on Windows, you can connect to Word using 'actxserver', insert and style any text you like into a blank document, copy and paste MATLAB figures into the document, and then save it to PDF. You can do all of that from within MATLAB. The first time you do this it's a pain, as you need to learn quite a bit about the Word Object Model; but once you've done it a couple of times it's very simple and quick, and you can achieve very professional results. You can combine this with using the 'export_fig' that others have mentioned.

R-tree implementation in matlab

please, any one tell me how we can implement the R-tree structure in matlab to speed the image retrieval system , I would like to inform you that my database space a feature vector of Color Histogram (Multidimensional ) and also I I have a distance vector for similarity measure...
thanks
I don't use Matlab. So I do not have any idea how much cost is associated in Matlab with index structures. It doesn't appear to be designed for such things.
R-Trees seem to make quite a difference. Judging from http://elki.dbs.ifi.lmu.de/wiki/Benchmarking some algorithms can benefit immensely from having a good index structure. The numbers on that web page are 5 to 7 times faster on a 110250 image color histogram data set.
From my experience, R-Trees can indeed be quite hard to get right. But only if you want to go the full way. If you have a static database, you can get easily away with a bulk loaded R-Tree. Neither the bulk loading nor the queries are very hard to do. R-Trees get messy once you want to do the R*-Tree optimizations with complex split strategies, reinsertions, balancing, and do all this efficiently and on-disk with smart caching. But as long as you are operating in-memory and do not dynamically add objects, a STR bulk-loaded R-tree will help a lot and be a lot easier to implement.
You might still be better off building on something that has already a working R-Tree. Say SQLite with the rtree module or ELKI mentioned above.
Implementing R-tree is not really a simple task. You can use matlab binding for the LidarK library, it should be fast enough. The code is here:
http://graphics.cs.msu.ru/en/science/research/3dpoint/lidark
If you decide to use kd-tree (which is typical for image retrieval), there's a good implementation too.
http://www.cs.ubc.ca/~mariusm/index.php/FLANN/FLANN
I'm not familiar with R-trees specifically but in general trees are dynamic data structures. Matlab doesn't really do dynamic data structures unless you start using its OO facilities. If you don't want to do that you can flatten your tree into a cell array. For example I'll write a (strictly) binary tree flattened into a cell array, which will save me having to draw a tree. Here goes:
{1,{2},{3}}
which represents a binary tree with root 1 and branches left to 2, right to 3. I can make this deeper:
{1,{2,{5,6}},{3,{7,8}}}
which adds another level to the previous tree. If you want to add data at any of the nodes, then your (first) tree might look like this:
{1,[a b c],{2,[e f]},{3,[h i j k l]}}
An alternative to this would be to define your nodes separately, like this
node1 = [a b c]; node2 = [e f]; node3 = [h i j k l],
then your tree becomes
{node1, node2, node3}
Your problem then becomes writing functions to build and to traverse the tree in your chosen representation. Most tree functions are best written as recursions. Any good text, and lots of Internet sites, will tell you all that you want to know about such functions.