I am using Neo4J as my underlying GraphDB, with Tinkerpop 3.3.1 on top in my Java application. I create the Graph in Java with Neo4JGraph.open ("/tmp/filename"), and then from there I only use the Tinkerpop Java API to create nodes, edges and run traversals.
I want to perform a Dijkstra shortest path on my Tinkerpop graph. Neo4J, which is my underlying GraphDB, has this algorithm built in, so I would like to use it. I use the make this call to get the Neo4J graph, and get a few Neo4JNode types from it.
Neo4jGraphAPI neo4J = this.graphPV.getBaseGraph();
Neo4jNode start = neo4J.getNodeById(1);
Neo4jNode end = neo4J.getNodeById(2);
This works, but now I'm not sure what to do next. I figured I would pass these nodes to the Neo4J pathfinder, but the findSinglePath method takes a Node type, not a Tinkerpop based Neo4JNode. I tried casting, that threw an exception. Can I convert the Tinkerpop Neo4JNode into a Neo4J Node type that the underlying Neo4J API will accept ?
dijkstraPathFinder = GraphAlgoFactory.dijkstra(expander, costEvaluator );
WeightedPath path = dijkstraPathFinder.findSinglePath((Node)start, (Node)end );
Results in:
WARNING: service exception java.lang.ClassCastException: org.neo4j.tinkerpop.api.impl.Neo4jNodeImpl cannot be cast to org.neo4j.graphdb.Node