public class NeighbourHelper {
public static int[] getNeighbours(int vertexId, final Graph graph) {
Integer[] vertices = new Integer[graph.vertices().length-1];
final Vertex vertex = graph.vertices()[vertexId];
int index=0;
boolean foundVertex = false;
for (int i=0; i < graph.vertices().length; i++) {
if (i==vertexId) {
continue;
}
// if (!vertex.equals(graph.vertices()[i])) {
vertices[index++]=i;
// } else {
// if (foundVertex) {
// throw new RuntimeException("ung�ltiger Graph: doppelter Knoten");
// }
// foundVertex=true;
// }
}
Arrays.sort(vertices, new Comparator<Integer>(){
public int compare(Integer o1, Integer o2) {
Vertex v1 = graph.vertices()[o1.intValue()];
Vertex v2 = graph.vertices()[o2.intValue()];
double dist1 = Vertex.getDistanceTo(vertex, v1);
double dist2 = Vertex.getDistanceTo(vertex, v2);
if (dist1 < dist2) {
return -1;
} else if (dist1 > dist2) {