Created
July 29, 2012 13:00
-
-
Save darekmydlarz/3198558 to your computer and use it in GitHub Desktop.
Scala + Neo4j + Blueprints
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.tinkerpop.blueprints.Graph | |
import com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph | |
import com.tinkerpop.blueprints.Vertex | |
import com.tinkerpop.blueprints.Edge | |
import java.util.Iterator | |
import com.tinkerpop.blueprints.Direction | |
object BlueprintsNeo4j { | |
def main(args: Array[String]): Unit = { | |
val graph : Graph = new Neo4jGraph("tmp/graph") | |
val a : Vertex = graph.addVertex() | |
val b : Vertex = graph.addVertex() | |
a.setProperty("name", "Marko") | |
b.setProperty("name", "Polo") | |
val e : Edge = graph.addEdge(null, a, b, "knows") | |
e.setProperty("since", 2006) | |
val it = a.getEdges(Direction.BOTH).iterator(); | |
while(it.hasNext()) { | |
val edge : Edge = it.next() | |
val v1 : Vertex = edge.getVertex(Direction.IN) | |
val v2 : Vertex = edge.getVertex(Direction.OUT) | |
println(v1.getProperty("name") + " knows " + v2.getProperty("name") + " since " + edge.getProperty("since")) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment