Package org.aisearch.data

Examples of org.aisearch.data.Path


  }

  private List<XMLArtefactOperation> search(INode startNode,
      IGoalTest goalTest, IQueueInserter queueInserter) {
    UninformedSearch search = new UninformedSearch(goalTest, queueInserter);
    Path solution = search.search(startNode);
    if (solution == null)
      return null;

    List<XMLArtefactOperation> operations = new ArrayList<XMLArtefactOperation>();
    while (solution != null) {
      MetaArtefactOperation operation = ((Node) solution.getLastEdge()
          .getTargetNode()).getOperation();
      if (operation == null)
        break;
      operations.add(0, new XMLArtefactOperation(operation.getId()));
      solution = solution.getPrePath();
    }

    return operations;
  }
View Full Code Here


    this.queueInserter = queueInserter;
  }

  public Path search(INode start) {
    List<Path> queue = new ArrayList<Path>();
    queue.add(new Path(null, new Edge(start, 0)));

    while (true) {
      if (queue.isEmpty())
        return null;
      Path bestPath = queue.remove(0);
      INode currentNode = bestPath.getLastEdge().getTargetNode();
      if (goalTest.isGoal(currentNode))
        return bestPath;
      List<Path> newPaths = new ArrayList<Path>();
      for (Edge edge : currentNode.generateSuccessors()) {
        if (bestPath.containsNode(edge.getTargetNode()))
          continue;
        newPaths.add(new Path(bestPath, edge));
      }
      queueInserter.insert(queue, newPaths);
    }
  }
View Full Code Here

TOP

Related Classes of org.aisearch.data.Path

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.