Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
64 lines (39 sloc) 1.39 KB


A thin wrapper for the titan libary [] this libary dosent wrapp the data types it only gives you some nicer functions and macros that can use keywords and maps

;; !!!!! example !!!!!!

;; include the libary
(use 'clj-titan.core)

(def graph (open "/tmp/titan-data"))

;; create some data
(with-graph graph

 (let [

   ;; a person 
   nils (vertex { :name "Nils" :email "some@something" })
   bert (vertex { :name "Bert" :email "bert@something" })

   bossy (vertex { :name "BossyBoss" :email "theboss@something" })]

   ;; create some relationshipp's

   (edge nils bossy :boss {})
   (edge bert bossy :boss {})

   (edge nils bert :freands {})))

;; print out a some clojure data

(use 'clojure.pprint)

 (map #(data % 5) ;; 5 is the depth of the tree to print
   (all-vertices graph))) ;; can also use the with-graph macro

;; more functions are

(edges vert) ;; all edges of a vertex
(id vert) ;; gets the id of a element
(from-direction edge :in) ;; gets you the vertex in the direction :out /
(fields element) ;; a map of the fields in the element
 ~@code) ;; run code in a transaction rollback if exception

(other-end edge vert) ;; given a edge and a vertex gives you the
vertex att the other side


Copyright © 2012 FIXME

Distributed under the Eclipse Public License, the same as Clojure.

Jump to Line
Something went wrong with that request. Please try again.