// Path: src/main/java/com/pathfinder/api/GraphTraversalService.java
// public interface GraphTraversalService extends Remote {
// 
//   /**
//    * @param origin origin point
//    * @param destination destination point
//    * @param limitations restrictions on the path selection, as key-value according to some API specification
//    * @return A list of transit paths
//    * @throws java.rmi.RemoteException RMI problem
//    */
//   List<TransitPath> findShortestPath(String origin,
//                                      String destination,
//                                      Properties limitations);
// 
// }
// 
// Path: src/main/java/com/pathfinder/api/TransitEdge.java
// public final class TransitEdge implements Serializable {
// 
//   private final String edge;
//   private final String fromNode;
//   private final String toNode;
//   private final Date fromDate;
//   private final Date toDate;
// 
//   /**
//    * Constructor.
//    *
//    * @param edge
//    * @param fromNode
//    * @param toNode
//    * @param fromDate
//    * @param toDate
//    */
//   public TransitEdge(final String edge,
//                      final String fromNode,
//                      final String toNode,
//                      final Date fromDate,
//                      final Date toDate) {
//     this.edge = edge;
//     this.fromNode = fromNode;
//     this.toNode = toNode;
//     this.fromDate = fromDate;
//     this.toDate = toDate;
//   }
// 
//   public String getEdge() {
//     return edge;
//   }
// 
//   public String getFromNode() {
//     return fromNode;
//   }
// 
//   public String getToNode() {
//     return toNode;
//   }
// 
//   public Date getFromDate() {
//     return fromDate;
//   }
// 
//   public Date getToDate() {
//     return toDate;
//   }
// }


import com.pathfinder.api.GraphTraversalService;
import com.pathfinder.api.TransitEdge;
import com.pathfinder.api.TransitPath;
import java.util.*;
package com.pathfinder.internal;



public class GraphTraversalServiceImpl implements GraphTraversalService {

  private GraphDAO dao;
  private Random random;
  private static final long ONE_MIN_MS = 1000 * 60;
  private static final long ONE_DAY_MS = ONE_MIN_MS * 60 * 24;

  public GraphTraversalServiceImpl(GraphDAO dao) {
    this.dao = dao;
    this.random = new Random();
  }

  public List<TransitPath> findShortestPath(final String originNode,
                                            final String destinationNode,
                                            final Properties limitations) {
    Date date = nextDate(new Date());

    List<String> allVertices = dao.listAllNodes();
    allVertices.remove(originNode);
    allVertices.remove(destinationNode);

    final int candidateCount = getRandomNumberOfCandidates();
    final List<TransitPath> candidates = new ArrayList<TransitPath>(candidateCount);

    for (int i = 0; i < candidateCount; i++) {
      allVertices = getRandomChunkOfNodes(allVertices);
// Path: src/main/java/com/pathfinder/api/GraphTraversalService.java
// public interface GraphTraversalService extends Remote {
// 
//   /**
//    * @param origin origin point
//    * @param destination destination point
//    * @param limitations restrictions on the path selection, as key-value according to some API specification
//    * @return A list of transit paths
//    * @throws java.rmi.RemoteException RMI problem
//    */
//   List<TransitPath> findShortestPath(String origin,
//                                      String destination,
//                                      Properties limitations);
// 
// }
// 
// Path: src/main/java/com/pathfinder/api/TransitEdge.java
// public final class TransitEdge implements Serializable {
// 
//   private final String edge;
//   private final String fromNode;
//   private final String toNode;
//   private final Date fromDate;
//   private final Date toDate;
// 
//   /**
//    * Constructor.
//    *
//    * @param edge
//    * @param fromNode
//    * @param toNode
//    * @param fromDate
//    * @param toDate
//    */
//   public TransitEdge(final String edge,
//                      final String fromNode,
//                      final String toNode,
//                      final Date fromDate,
//                      final Date toDate) {
//     this.edge = edge;
//     this.fromNode = fromNode;
//     this.toNode = toNode;
//     this.fromDate = fromDate;
//     this.toDate = toDate;
//   }
// 
//   public String getEdge() {
//     return edge;
//   }
// 
//   public String getFromNode() {
//     return fromNode;
//   }
// 
//   public String getToNode() {
//     return toNode;
//   }
// 
//   public Date getFromDate() {
//     return fromDate;
//   }
// 
//   public Date getToDate() {
//     return toDate;
//   }
// }


// Path: src/main/java/com/pathfinder/internal/GraphTraversalServiceImpl.java
import com.pathfinder.api.GraphTraversalService;
import com.pathfinder.api.TransitEdge;
import com.pathfinder.api.TransitPath;
import java.util.*;

package com.pathfinder.internal;



public class GraphTraversalServiceImpl implements GraphTraversalService {

  private GraphDAO dao;
  private Random random;
  private static final long ONE_MIN_MS = 1000 * 60;
  private static final long ONE_DAY_MS = ONE_MIN_MS * 60 * 24;

  public GraphTraversalServiceImpl(GraphDAO dao) {
    this.dao = dao;
    this.random = new Random();
  }

  public List<TransitPath> findShortestPath(final String originNode,
                                            final String destinationNode,
                                            final Properties limitations) {
    Date date = nextDate(new Date());

    List<String> allVertices = dao.listAllNodes();
    allVertices.remove(originNode);
    allVertices.remove(destinationNode);

    final int candidateCount = getRandomNumberOfCandidates();
    final List<TransitPath> candidates = new ArrayList<TransitPath>(candidateCount);

    for (int i = 0; i < candidateCount; i++) {
      allVertices = getRandomChunkOfNodes(allVertices);
      final List<TransitEdge> transitEdges = new ArrayList<TransitEdge>(allVertices.size() - 1);