Browse files

Added some examples to the README file

and a function for get all the vertices of
a graph
  • Loading branch information...
1 parent 921fe5e commit 8e3f0fd5e277c580c097ce7825f2bc7d2a4aeb9e @megakorre megakorre committed Jun 15, 2012
Showing with 58 additions and 0 deletions.
  1. +54 −0 README.md
  2. +4 −0 src/clj_titan/core.clj
View
54 README.md
@@ -1,7 +1,61 @@
# clj-titan
A thin wrapper for the titan libary [https://github.com/thinkaurelius/titan/wiki]
+this libary dosent wrapp the data types it only gives you some
+nicer functions and macros that can use keywords and maps
+```clojure
+
+;; !!!!! 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" })
+
+ ;; note you can also asign a id to a vertex
+ 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)
+
+(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) ;; gets you the vertex in the direction :out /
+:in
+(fields element) ;; a map of the fields in the element
+(with-transaction
+ ~@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
+
+
+
+```
## License
View
4 src/clj_titan/core.clj
@@ -111,6 +111,10 @@ src/main/java/com/tinkerpop/blueprints/Vertex.java"
[id]
(.getVertex *graph* id))
+(defn all-vertices
+ []
+ (.getVerices *graph*))
+
(defn data-dispatch
[thing]
(cond

0 comments on commit 8e3f0fd

Please sign in to comment.