public Byte getInternetDistanceBFS(int as1, int as2) {

		// if Distances for AS1 are not created yet - create them
		if (distances.get(as1) == null) {
			distances.put(as1, new Distances());
		}

		if (distances.get(as1).getDistance(as2) != null) { // if distance was
															// already found,
															// return it.
			return distances.get(as1).getDistance(as2);
		} else { // start Breadth-First-Search

			// array where I save vertices found
			Set<Integer> foundVerticies = new HashSet<Integer>();

			// FIFO queue where I put new vertices
			Queue<Integer> queue = new LinkedList<Integer>();

			// add first AS to the graph and add it to the queue
			foundVerticies.add(as1);
			queue.add(as1);

			// set distance to itself for first vertex
			distances.get(as1).setDistance(as1, (byte) 0);

			while (!queue.isEmpty()) {
				// get and remove first element from the queue
				int currentVertex = queue.poll();

				// get all neighbours of current vertex, mark them and add to
				// the queue if not found earlier
				if (this.getNeighbours(currentVertex) != null) {
					for (Integer neighbour : this.getNeighbours(currentVertex)) {
						if (!foundVerticies.contains(neighbour)) {
							// mark as found and add to the queue
							foundVerticies.add(neighbour);
							queue.add(neighbour);

							// set distance for neighbour found
							if (distances.get(as1).getDistance(currentVertex) < 127) { // check
																						// if
																						// distance
																						// to
																						// currentVertex
																						// is
																						// less
																						// than
																						// infinity
								distances.get(as1).setDistance(
										// set distance
										neighbour,
										(byte) (distances.get(as1).getDistance(
												currentVertex) + 1));
							} else {
								distances.get(as1).setDistance(neighbour, // set
																			// infinite
																			// distance
																			// (127)
										(byte) 127);
							}

							if (neighbour == as2) { // if as2 was reached -
													// return
													// result
								return distances.get(as1)
										.getDistance(neighbour);
							}
						}
					}
				}
			}

			// If I'm here, the as2 was not reached
			distances.get(as1).setDistance(as2, (byte) 127); // set distance to
																// infinity
			return (byte) 127;

		}
	}