public Path makePath(final boolean includeEdges, final String... names) {
        Path path = ImmutablePath.make();
        boolean first = true;
        for (final String name : names) {
            final Vertex vertex = vertexCache.computeIfAbsent(name, test::convertToVertex);
            if (!first) {
                if (includeEdges) {
                    final Object id1 = ((Vertex) path.get(path.size() - 1)).id();
                    final Object id2 = vertex.id();
                    final Edge edge;
                    if (edgeCache.containsKey(id1)) {
                        edge = edgeCache.get(id1).computeIfAbsent(id2, id -> getEdge(id1, id));
                    } else if (edgeCache.containsKey(id2)) {
                        edge = edgeCache.get(id2).computeIfAbsent(id1, id -> getEdge(id, id2));
                    } else {
                        edgeCache.put(id1, new HashMap<>());
                        edgeCache.get(id1).put(id2, edge = getEdge(id1, id2));
                    }
                    path = path.extend(edge, Collections.emptySet());
                }
            }
            path = path.extend(vertex, Collections.emptySet());
            first = false;
        }
        return path;
    }
@author Daniel Kuppitz (http://gremlin.guru)
gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/search/path/ShortestPathTestHelper.java