public static int getContactDist(Integer pS, Integer pD, int maxDistLim) {
		LinkedList<Integer> q = new LinkedList<Integer>();
		q.add(pS);
		HashSet<Integer> visited = new HashSet<Integer>();
		visited.add(pS);
		HashSet<Integer> done = new HashSet<Integer>();
		HashMap<Integer,Integer> distances = new HashMap<Integer,Integer>();
		distances.put(pS, new Integer(0));
		int maxDist = 0;
		while (q.size() > 0 && maxDist < maxDistLim && !distances.containsKey(pD)) {
			Integer u = q.poll();
			Iterator<Integer> neighbors = getNeighbors(u).iterator();
			while (neighbors.hasNext()) {
				Integer v = neighbors.next();
				if (!visited.contains(v) && !done.contains(v)) {
					int d = distances.get(u).intValue() + 1;
					distances.put(v, new Integer(d));
					visited.add(v);
					q.add(v);
					if (d > maxDist)
						maxDist = d;
				}
			}
			done.add(u);
		}
		if (distances.containsKey(pD))
			return distances.get(pD).intValue();
		else
			return -1;
	}