Closed m0smith closed 11 years ago
Graph.addEdge requires an id, but it looks like it can be null, at least for TinkerGraph.
I checked neo4j orient and dex and all three accept a null as the id. Looks like it would be safe to pass null as the first argument to Graph.addEdge from the connect! function.
Graph.addVertex
and Graph.addEdge
can take an optional id depending on the implementation of Tinkerpop. If you pass null in, the db is supposed to assign it for you. Titan, and perhaps other implementations, don't even give you the option of passing in an id, they simply assign the id to the object for you. connect
was made for the instances when you don't have to pass in an id, while connect-with-id
when you want to pass in an id, either null or some real value.
Does that help?
Looking at the source code for Graph: https://github.com/tinkerpop/blueprints/blob/master/blueprints-core/src/main/java/com/tinkerpop/blueprints/Graph.java
I can only see one addEdge method signature and it had id as the first argument.
public Edge addEdge(Object id, Vertex outVertex, Vertex inVertex, String label);
The call to addEdge in connect!
does not include the id:
(.addEdge ^Graph *graph* v1 v2 ^String (name label))
It looks like it should be:
(.addEdge ^Graph *graph* nil v1 v2 ^String (name label))
Titan uses (.addEdge ^Graph *graph* v1 v2 ^String (name label))
, because it doesn't allow you to provide id's. connect-with-id
works for your use case. What's the problem?
I added a test case to edge_test called test-connect!
: https://github.com/m0smith/archimedes/blob/master/test/archimedes/edge_test.clj
It shows the failure. The test is the same as the test-delete
above it but using connect!
rather than connect-with-id!
The error I am seeing is trying to use connect!
in edge.clj (line 126): https://github.com/clojurewerkz/archimedes/blob/master/src/archimedes/edge.clj#L126
@m0smith the issue is that Titan (the primary graph implementation ClojureWerkz project target) only uses automatically generated IDs. You need to use connect-with-id
instead.
in alpha5, edge/connect! fails using TinkerGraph topoged.data.blueprints> (e/connect! (first v) :dummy (second v))
IllegalArgumentException No matching method found: addEdge for class com.tinkerpop.blueprints.impls.tg.TinkerGraph \ clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:53)
but edge/connect-with-id! works
topoged.data.blueprints> (e/connect-with-id! "id" (first v) :dummy (second v))
<TinkerEdge e[id][18-dummy->19]>