public static boolean contains(EdgeIterator iter, int... locs) {
    TIntHashSet set = new TIntHashSet();

    while (iter.next()) {
      set.add(iter.node());
    }
    for (int l : locs) {
      if (!set.contains(l)) return false;
    }
    return true;
  }
  /** @throws could throw exception if uncatched problems like index out of bounds etc */
  public static List<String> getProblems(Graph g) {
    List<String> problems = new ArrayList<String>();
    int nodes = g.getNodes();
    for (int i = 0; i < nodes; i++) {
      double lat = g.getLatitude(i);
      if (lat > 90 || lat < -90) problems.add("latitude is not within its bounds " + lat);
      double lon = g.getLongitude(i);
      if (lon > 180 || lon < -180) problems.add("longitude is not within its bounds " + lon);
      int incom = count(g.getIncoming(i));
      int out = count(g.getOutgoing(i));
      int e = count(g.getEdges(i));
      if (Math.max(out, incom) > e)
        problems.add(
            "count incoming or outgoing edges should be maximum "
                + e
                + " but were:"
                + incom
                + "(in), "
                + out
                + "(out)");

      EdgeIterator iter = g.getEdges(i);
      while (iter.next()) {
        if (iter.node() >= nodes)
          problems.add(
              "edge of " + i + " has a node " + iter.node() + " greater or equal to getNodes");
        if (iter.node() < 0) problems.add("edge of " + i + " has a negative node " + iter.node());
      }
    }

    //        for (int i = 0; i < nodes; i++) {
    //            new XFirstSearch().start(g, i, false);
    //        }

    return problems;
  }
 public static EdgeIterator until(EdgeIterator edges, int i) {
   while (edges.next()) {
     if (edges.node() == i) return edges;
   }
   return EdgeIterator.EMPTY;
 }