public double search(int start, int target) {
      List<State> bfs = new LinkedList<State>();
      State init = new State(start);
      bfs.add(init);
      while (bfs.size() > 0) {
        State cur = bfs.remove(0);
        int state = cur.state;
        if (state == target) {
          return cur.rate;
        }

        for (int x = 0; x < 8; x++) {
          if (rates[x][state] != 0 && !cur.visited.contains(x)) {
            State newstate = cur.visit(x, rates[x][state]);
            bfs.add(newstate);
          }
        }
      }
      return 0;
    }