/** Populates the result from the graph traversal state. */
  private void assembleResult(ResolveState resolveState, DependencyGraphVisitor listener) {
    listener.start(resolveState.root);

    // Visit the nodes
    for (ConfigurationNode resolvedConfiguration : resolveState.getConfigurationNodes()) {
      if (resolvedConfiguration.isSelected()) {
        resolvedConfiguration.validate();
        listener.visitNode(resolvedConfiguration);
      }
    }
    // Visit the edges
    for (ConfigurationNode resolvedConfiguration : resolveState.getConfigurationNodes()) {
      if (resolvedConfiguration.isSelected()) {
        listener.visitEdge(resolvedConfiguration);
      }
    }

    listener.finish(resolveState.root);
  }
 public void validate() {
   for (DependencyEdge incomingEdge : incomingEdges) {
     ConfigurationNode fromNode = incomingEdge.from;
     if (!fromNode.isSelected()) {
       throw new IllegalStateException(
           String.format(
               "Unexpected state %s for parent node for dependency from %s to %s.",
               fromNode.moduleRevision.state, fromNode, this));
     }
   }
 }