use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class VertexPredicateTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
graph = new OrientGraph("memory:" + VertexPredicateTest.class.getSimpleName());
graph.createEdgeType("Friend");
luca = graph.addVertex(null, "name", "Luca");
bill = graph.addVertex(null, "name", "Bill");
luca.addEdge("Friend", bill);
jay = graph.addVertex(null, "name", "Jay");
bill.addEdge("Friend", jay);
steve = graph.addVertex(null, "name", "Steve");
jay.addEdge("Friend", steve);
// GRAPH IS: luca -> bill -> jay -> steve
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class RequireTransactionTest method beforeClass.
@BeforeClass
public static void beforeClass() {
if (graph == null) {
final String dbName = GraphTxAbstractTest.class.getSimpleName();
final String storageType = getStorageType();
final String buildDirectory = System.getProperty("buildDirectory", ".");
graph = new OrientGraph(storageType + ":" + buildDirectory + "/" + dbName);
graph.drop();
graph = new OrientGraph(storageType + ":" + buildDirectory + "/" + dbName);
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class OSQLFunctionAstarTest method setUpDatabase.
private void setUpDatabase() {
dbCounter++;
graph = new OrientGraph("memory:OSQLFunctionAstarTest" + dbCounter);
graph.createEdgeType("has_path");
OFunction cf = graph.getRawGraph().getMetadata().getFunctionLibrary().createFunction("myCustomHeuristic");
cf.setCode("return 1;");
v0 = graph.addVertex(null);
v1 = graph.addVertex(null);
v2 = graph.addVertex(null);
v3 = graph.addVertex(null);
v4 = graph.addVertex(null);
v5 = graph.addVertex(null);
v6 = graph.addVertex(null);
// Tabriz
v0.setProperty("node_id", "Z");
v0.setProperty("name", "Tabriz");
v0.setProperty("lat", 31.746512f);
v0.setProperty("lon", 51.427002f);
v0.setProperty("alt", 2200);
// Tehran
v1.setProperty("node_id", "A");
v1.setProperty("name", "Tehran");
v1.setProperty("lat", 35.746512f);
v1.setProperty("lon", 51.427002f);
v1.setProperty("alt", 1800);
// Mecca
v2.setProperty("node_id", "B");
v2.setProperty("name", "Mecca");
v2.setProperty("lat", 21.371244f);
v2.setProperty("lon", 39.847412f);
v2.setProperty("alt", 1500);
// Bejin
v3.setProperty("node_id", "C");
v3.setProperty("name", "Bejin");
v3.setProperty("lat", 39.904041f);
v3.setProperty("lon", 116.408011f);
v3.setProperty("alt", 1200);
// London
v4.setProperty("node_id", "D");
v4.setProperty("name", "London");
v4.setProperty("lat", 51.495065f);
v4.setProperty("lon", -0.120850f);
v4.setProperty("alt", 900);
// NewYork
v5.setProperty("node_id", "E");
v5.setProperty("name", "NewYork");
v5.setProperty("lat", 42.779275f);
v5.setProperty("lon", -74.641113f);
v5.setProperty("alt", 1700);
// Los Angles
v6.setProperty("node_id", "F");
v6.setProperty("name", "Los Angles");
v6.setProperty("lat", 34.052234f);
v6.setProperty("lon", -118.243685f);
v6.setProperty("alt", 400);
Edge e1 = graph.addEdge(null, v1, v2, "has_path");
e1.setProperty("weight", 250.0f);
e1.setProperty("ptype", "road");
Edge e2 = graph.addEdge(null, v2, v3, "has_path");
e2.setProperty("weight", 250.0f);
e2.setProperty("ptype", "road");
Edge e3 = graph.addEdge(null, v1, v3, "has_path");
e3.setProperty("weight", 1000.0f);
e3.setProperty("ptype", "road");
Edge e4 = graph.addEdge(null, v3, v4, "has_path");
e4.setProperty("weight", 250.0f);
e4.setProperty("ptype", "road");
Edge e5 = graph.addEdge(null, v2, v4, "has_path");
e5.setProperty("weight", 600.0f);
e5.setProperty("ptype", "road");
Edge e6 = graph.addEdge(null, v4, v5, "has_path");
e6.setProperty("weight", 400.0f);
e6.setProperty("ptype", "road");
Edge e7 = graph.addEdge(null, v5, v6, "has_path");
e7.setProperty("weight", 300.0f);
e7.setProperty("ptype", "road");
Edge e8 = graph.addEdge(null, v3, v6, "has_path");
e8.setProperty("weight", 200.0f);
e8.setProperty("ptype", "road");
Edge e9 = graph.addEdge(null, v4, v6, "has_path");
e9.setProperty("weight", 900.0f);
e9.setProperty("ptype", "road");
Edge e10 = graph.addEdge(null, v2, v6, "has_path");
e10.setProperty("weight", 2500.0f);
e10.setProperty("ptype", "road");
Edge e11 = graph.addEdge(null, v1, v5, "has_path");
e11.setProperty("weight", 100.0f);
e11.setProperty("ptype", "road");
Edge e12 = graph.addEdge(null, v4, v1, "has_path");
e12.setProperty("weight", 200.0f);
e12.setProperty("ptype", "road");
Edge e13 = graph.addEdge(null, v5, v3, "has_path");
e13.setProperty("weight", 800.0f);
e13.setProperty("ptype", "road");
Edge e14 = graph.addEdge(null, v5, v2, "has_path");
e14.setProperty("weight", 500.0f);
e14.setProperty("ptype", "road");
Edge e15 = graph.addEdge(null, v6, v5, "has_path");
e15.setProperty("weight", 250.0f);
e15.setProperty("ptype", "road");
Edge e16 = graph.addEdge(null, v3, v1, "has_path");
e16.setProperty("weight", 550.0f);
e16.setProperty("ptype", "road");
graph.commit();
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class OSQLFunctionDijkstraTest method setUpDatabase.
private void setUpDatabase() {
graph = new OrientGraph("memory:OSQLFunctionDijkstraTest");
graph.createEdgeType("weight");
v1 = graph.addVertex(null);
v2 = graph.addVertex(null);
v3 = graph.addVertex(null);
v4 = graph.addVertex(null);
v1.setProperty("node_id", "A");
v2.setProperty("node_id", "B");
v3.setProperty("node_id", "C");
v4.setProperty("node_id", "D");
Edge e1 = graph.addEdge(null, v1, v2, "weight");
e1.setProperty("weight", 1.0f);
Edge e2 = graph.addEdge(null, v2, v3, "weight");
e2.setProperty("weight", 1.0f);
Edge e3 = graph.addEdge(null, v1, v3, "weight");
e3.setProperty("weight", 100.0f);
Edge e4 = graph.addEdge(null, v3, v4, "weight");
e4.setProperty("weight", 1.0f);
graph.commit();
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class OSQLFunctionShortestPathTest method setUpDatabase.
private void setUpDatabase() {
graph = new OrientGraph("memory:OSQLFunctionShortestPath");
vertices.put(1, graph.addVertex(null));
vertices.put(2, graph.addVertex(null));
vertices.put(3, graph.addVertex(null));
vertices.put(4, graph.addVertex(null));
vertices.get(1).setProperty("node_id", "A");
vertices.get(2).setProperty("node_id", "B");
vertices.get(3).setProperty("node_id", "C");
vertices.get(4).setProperty("node_id", "D");
graph.addEdge(null, vertices.get(1), vertices.get(2), "Edge1");
graph.addEdge(null, vertices.get(2), vertices.get(3), "Edge1");
graph.addEdge(null, vertices.get(3), vertices.get(1), "Edge2");
graph.addEdge(null, vertices.get(3), vertices.get(4), "Edge1");
for (int i = 5; i <= 20; i++) {
vertices.put(i, graph.addVertex(null));
vertices.get(i).setProperty("node_id", "V" + i);
graph.addEdge(null, vertices.get(i - 1), vertices.get(i), "Edge1");
if (i % 2 == 0) {
graph.addEdge(null, vertices.get(i - 2), vertices.get(i), "Edge1");
}
}
graph.commit();
}
Aggregations