use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project blueprints by tinkerpop.
the class SailLoaderTest method testAll.
@Test
public void testAll() throws Exception {
KeyIndexableGraph g = new TinkerGraph();
Sail sail = new GraphSail(g);
sail.initialize();
try {
SailLoader loader = new SailLoader(sail);
File f = resourceToFile("graph-example-sail-test.trig");
SailConnection sc = sail.getConnection();
try {
sc.begin();
assertEquals(0, sc.size());
loader.load(f);
sc.rollback();
assertEquals(29, sc.size());
} finally {
sc.close();
}
} finally {
sail.shutDown();
}
}
use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project blueprints by tinkerpop.
the class GraphJungTest method testTinkerGraph.
public void testTinkerGraph() {
GraphJung<TinkerGraph> jung = new GraphJung<TinkerGraph>(TinkerGraphFactory.createTinkerGraph());
assertEquals(jung.getVertices().size(), 6);
assertEquals(jung.getEdges().size(), 6);
assertEquals(jung.getVertexCount(), 6);
assertEquals(jung.getEdgeCount(), 6);
Vertex marko = null;
Vertex josh = null;
Vertex vadas = null;
for (Vertex vertex : jung.getVertices()) {
assertTrue(jung.containsVertex(vertex));
for (Edge edge : jung.getOutEdges(vertex)) {
assertEquals(jung.getSource(edge), vertex);
}
for (Edge edge : jung.getInEdges(vertex)) {
assertEquals(jung.getDest(edge), vertex);
}
if (vertex.getId().equals("1")) {
marko = vertex;
assertEquals(jung.getOutEdges(vertex).size(), 3);
assertEquals(jung.getInEdges(vertex).size(), 0);
assertEquals(jung.getNeighborCount(vertex), 3);
int count = 0;
for (Vertex vertex2 : jung.getNeighbors(vertex)) {
if (vertex2.getId().equals("2"))
count++;
else if (vertex2.getId().equals("4"))
count++;
else if (vertex2.getId().equals("3"))
count++;
else
assertTrue(false);
}
assertEquals(count, 3);
assertEquals(jung.getSuccessorCount(vertex), 3);
count = 0;
for (Vertex vertex2 : jung.getSuccessors(vertex)) {
if (vertex2.getId().equals("2"))
count++;
else if (vertex2.getId().equals("4"))
count++;
else if (vertex2.getId().equals("3"))
count++;
else
assertTrue(false);
}
assertEquals(jung.getPredecessorCount(vertex), 0);
} else if (vertex.getId().equals("2")) {
vadas = vertex;
assertEquals(jung.getOutEdges(vertex).size(), 0);
assertEquals(jung.getInEdges(vertex).size(), 1);
assertEquals(jung.getNeighborCount(vertex), 1);
int count = 0;
for (Vertex vertex2 : jung.getNeighbors(vertex)) {
if (vertex2.getId().equals("1"))
count++;
else
assertTrue(false);
}
assertEquals(count, 1);
assertEquals(jung.getSuccessorCount(vertex), 0);
assertEquals(jung.getPredecessorCount(vertex), 1);
count = 0;
for (Vertex vertex2 : jung.getPredecessors(vertex)) {
if (vertex2.getId().equals("1"))
count++;
else
assertTrue(false);
}
assertEquals(count, 1);
} else if (vertex.getId().equals("4")) {
josh = vertex;
assertEquals(jung.getOutEdges(vertex).size(), 2);
assertEquals(jung.getInEdges(vertex).size(), 1);
assertEquals(jung.getNeighborCount(vertex), 3);
int count = 0;
for (Vertex vertex2 : jung.getNeighbors(vertex)) {
if (vertex2.getId().equals("1"))
count++;
else if (vertex2.getId().equals("3"))
count++;
else if (vertex2.getId().equals("5"))
count++;
else
assertTrue(false);
}
assertEquals(count, 3);
assertEquals(jung.getSuccessorCount(vertex), 2);
count = 0;
for (Vertex vertex2 : jung.getSuccessors(vertex)) {
if (vertex2.getId().equals("3"))
count++;
else if (vertex2.getId().equals("5"))
count++;
else
assertTrue(false);
}
assertEquals(count, 2);
assertEquals(jung.getPredecessorCount(vertex), 1);
count = 0;
for (Vertex vertex2 : jung.getPredecessors(vertex)) {
if (vertex2.getId().equals("1"))
count++;
else
assertTrue(false);
}
assertEquals(count, 1);
}
}
assertTrue(null != marko);
assertTrue(null != vadas);
assertTrue(null != josh);
assertEquals(jung.findEdgeSet(marko, josh).size(), 1);
assertTrue(jung.findEdgeSet(marko, josh).contains(jung.findEdge(marko, josh)));
assertEquals(jung.getDefaultEdgeType(), EdgeType.DIRECTED);
for (Edge edge : jung.getEdges()) {
assertTrue(jung.containsEdge(edge));
assertEquals(jung.getEdgeType(edge), EdgeType.DIRECTED);
assertEquals(jung.getIncidentCount(edge), 2);
}
}
use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project blueprints by tinkerpop.
the class ReadOnlyGraphTest method testWrappedElementUniqueness.
public void testWrappedElementUniqueness() {
Graph graph = new ReadOnlyGraph<TinkerGraph>(TinkerGraphFactory.createTinkerGraph());
assertEquals(graph.getVertex(1), graph.getVertex(1));
Set<Vertex> set = new HashSet<Vertex>();
set.add(graph.getVertex(2));
set.add(graph.getVertex(2));
assertEquals(set.size(), 1);
assertEquals(graph.getEdge(7).hashCode(), graph.getEdge(7).hashCode());
assertEquals(graph.getEdge(8), graph.getEdge(8));
}
use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project blueprints by tinkerpop.
the class TinkerGraphSailTest method testTmp.
@Test
public void testTmp() throws Exception {
KeyIndexableGraph g = new TinkerGraph();
GraphSail sail = new GraphSail(g, "sp,p,c,pc");
}
use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project frames by tinkerpop.
the class TypedGraphModuleTest method testDeserializeEdgeType.
public void testDeserializeEdgeType() {
Graph graph = new TinkerGraph();
FramedGraphFactory factory = new FramedGraphFactory(new TypedGraphModuleBuilder().withClass(A.class).withClass(B.class).withClass(C.class).build());
FramedGraph<Graph> framedGraph = factory.create(graph);
Vertex v1 = graph.addVertex(null);
Vertex v2 = graph.addVertex(null);
Edge cE = graph.addEdge(null, v1, v2, "label");
cE.setProperty("type", "C");
Base c = framedGraph.getEdge(cE.getId(), Direction.OUT, Base.class);
assertTrue(c instanceof C);
}
Aggregations