public void execute(final Vertex vertex, final GraphMemory graphMemory) {
    if (graphMemory.isInitialIteration()) {
      final List<List<Object>> paths = new ArrayList<List<Object>>();
      final List<Object> path = new ArrayList<Object>();
      path.add(vertex.getId());
      paths.add(path);
      vertex.setProperty(LIVE_PATHS, paths);
      vertex.setProperty(DEAD_PATHS, new HashMap<Object, List<Vertex>>());
    } else {

      final Map<Object, List<Object>> deadPaths = vertex.getProperty(DEAD_PATHS);
      final List<List<Object>> livePaths = new ArrayList<List<Object>>();

      for (final Vertex adjacent : this.incomingQuery.build(vertex).vertices()) {
        final List<List<Object>> paths = adjacent.getProperty(LIVE_PATHS);
        for (final List<Object> path : paths) {
          final List<Object> appendedPath = new ArrayList<Object>();
          appendedPath.addAll(path);
          appendedPath.add(vertex.getId());
          if (isSimple(appendedPath)) {
            if (!deadPaths.containsKey(path.get(0))) {
              deadPaths.put(path.get(0), appendedPath);
            }
            livePaths.add(appendedPath);
          }
        }
      }
      vertex.setProperty(LIVE_PATHS, livePaths);
      vertex.setProperty(DEAD_PATHS, deadPaths);
    }
  }
 public boolean terminate(final GraphMemory memory) {
   return memory.getIteration() == this.diameter;
 }