*/
@Test
@FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
public void shouldEvaluateConnectivityPatterns() {
final GraphProvider graphProvider = GraphManager.get();
final Graph graph = this.g;
final Vertex a;
final Vertex b;
final Vertex c;
final Vertex d;
if (graph.features().vertex().supportsUserSuppliedIds()) {
a = graph.addVertex(T.id, graphProvider.convertId("1"));
b = graph.addVertex(T.id, graphProvider.convertId("2"));
c = graph.addVertex(T.id, graphProvider.convertId("3"));
d = graph.addVertex(T.id, graphProvider.convertId("4"));
} else {
a = graph.addVertex();
b = graph.addVertex();
c = graph.addVertex();
d = graph.addVertex();
}
tryCommit(graph, assertVertexEdgeCounts(4, 0));
final Edge e = a.addEdge(graphProvider.convertLabel("knows"), b);
final Edge f = b.addEdge(graphProvider.convertLabel("knows"), c);
final Edge g = c.addEdge(graphProvider.convertLabel("knows"), d);
final Edge h = d.addEdge(graphProvider.convertLabel("knows"), a);
tryCommit(graph, assertVertexEdgeCounts(4, 4));
for (Vertex v : graph.V().toList()) {
assertEquals(new Long(1), v.outE().count().next());
assertEquals(new Long(1), v.inE().count().next());
}
for (Edge x : graph.E().toList()) {
assertEquals(graphProvider.convertLabel("knows"), x.label());
}
if (graph.features().vertex().supportsUserSuppliedIds()) {
final Vertex va = graph.v(graphProvider.convertId("1"));
final Vertex vb = graph.v(graphProvider.convertId("2"));
final Vertex vc = graph.v(graphProvider.convertId("3"));
final Vertex vd = graph.v(graphProvider.convertId("4"));
assertEquals(a, va);
assertEquals(b, vb);
assertEquals(c, vc);
assertEquals(d, vd);
assertEquals(new Long(1), va.inE().count().next());
assertEquals(new Long(1), va.outE().count().next());
assertEquals(new Long(1), vb.inE().count().next());
assertEquals(new Long(1), vb.outE().count().next());
assertEquals(new Long(1), vc.inE().count().next());
assertEquals(new Long(1), vc.outE().count().next());
assertEquals(new Long(1), vd.inE().count().next());
assertEquals(new Long(1), vd.outE().count().next());
final Edge i = a.addEdge(graphProvider.convertLabel("hates"), b);
assertEquals(new Long(1), va.inE().count().next());
assertEquals(new Long(2), va.outE().count().next());
assertEquals(new Long(2), vb.inE().count().next());
assertEquals(new Long(1), vb.outE().count().next());
assertEquals(new Long(1), vc.inE().count().next());
assertEquals(new Long(1), vc.outE().count().next());
assertEquals(new Long(1), vd.inE().count().next());
assertEquals(new Long(1), vd.outE().count().next());
for (Edge x : a.outE().toList()) {
assertTrue(x.label().equals(graphProvider.convertId("knows")) || x.label().equals(graphProvider.convertId("hates")));
}
assertEquals(graphProvider.convertId("hates"), i.label());
assertEquals(graphProvider.convertId("2"), i.inV().id().next().toString());
assertEquals(graphProvider.convertId("1"), i.outV().id().next().toString());
}
final Set<Object> vertexIds = new HashSet<>();
vertexIds.add(a.id());
vertexIds.add(a.id());