Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simple edge and vertex creation.

  • Loading branch information...
commit 16725bf7cec5477658e94735850fc907231c68a9 1 parent 92d49d0
Darrick Wiebe authored
Showing with 16 additions and 4 deletions.
  1. +16 −4 src/pacer/graph.clj
View
20 src/pacer/graph.clj
@@ -9,22 +9,34 @@
{ :source true
:type :graph
:name "TinkerGraph"
- :raw-graph (com.tinkerpop.blueprints.impls.tg.TinkerGraph.)
- :encoder (pacer/simple-encoder)})
+ :raw-graph (atom (com.tinkerpop.blueprints.impls.tg.TinkerGraph.))
+ :encoder (atom (pacer/simple-encoder))})
+
+(defn create-vertex [graph]
+ { :graph graph
+ :type :vertex
+ :element (.addVertex @(:raw-graph graph) nil)
+ })
+
+(defn create-edge [graph label from to]
+ { :graph graph
+ :type :edge
+ :element (.addEdge @(:raw-graph graph) nil (:element from) (:element to) (str label))
+ })
(defn v []
{ :source-type :graph
:type :vertex
:name "V"
:iterator (fn iterator [source]
- (.. (:raw-graph source) getVertices iterator)) })
+ (.. @(:raw-graph source) getVertices iterator)) })
(defn e []
{ :source-type :graph
:type :edge
:name "E"
:iterator (fn iterator [source]
- (.. (:raw-graph source) getEdges iterator)) })
+ (.. @(:raw-graph source) getEdges iterator)) })
(defn out-e [& labels]
{ :source-type :vertex
Please sign in to comment.
Something went wrong with that request. Please try again.