@Override
  public void validate(Definition definition) throws WorkflowException {
    State initialState = definition.getInitialState();

    if (initialState == null) {
      throw new WorkflowException("No initial state defined");
    }

    List<State> terminalStates = definition.getTerminalStates();

    if (terminalStates.isEmpty()) {
      throw new WorkflowException("No terminal states defined");
    }

    if (definition.getForksCount() != definition.getJoinsCount()) {
      throw new WorkflowException("There are unbalanced fork and join nodes");
    }

    Collection<Node> nodes = definition.getNodes();

    for (Node node : nodes) {
      NodeValidator<Node> nodeValidator =
          _nodeValidatorRegistry.getNodeValidator(node.getNodeType());

      nodeValidator.validate(definition, node);
    }
  }
  protected IRoutingAlgorithm createSolver(IRoutingLocation from) {
    boolean needReset = validator.increaseIteration();
    if (needReset) {
      for (ExperimentalDijkstraSearchNode node : nodes) {
        node.invalidate();
      }
    }

    lastLocation = from;

    Pair<List<Integer>, List<Double>> initial = computeSearchNodes(from);
    return new ExperimentalDijkstrasShortestPath(graph, initial.first(), initial.second(), nodes);
  }