vertexList.add((Object) vertexes[i]);
vertexListStatic.add((Object) vertexes[i]);
}
distances[vertexListStatic.indexOf(startVertex)] = 0;
mxCostFunction costFunction = aGraph.getGenerator().getCostFunction();
mxGraphView view = aGraph.getGraph().getView();
while (vertexList.size() > 0)
{
//find closest vertex
double minDistance;
Object currVertex;
Object closestVertex;
currVertex = vertexList.get(0);
int currIndex = vertexListStatic.indexOf(currVertex);
double currDistance = distances[currIndex];
minDistance = currDistance;
closestVertex = currVertex;
if (vertexList.size() > 1)
{
for (int i = 1; i < vertexList.size(); i++)
{
currVertex = vertexList.get(i);
currIndex = vertexListStatic.indexOf(currVertex);
currDistance = distances[currIndex];
if (currDistance < minDistance)
{
minDistance = currDistance;
closestVertex = currVertex;
}
}
}
// we found the closest vertex
vertexList.remove(closestVertex);
Object currEdge = new Object();
Object[] neighborVertices = aGraph.getOpposites(aGraph.getEdges(closestVertex, null, true, true, false, true), closestVertex,
true, true);
for (int j = 0; j < neighborVertices.length; j++)
{
Object currNeighbor = neighborVertices[j];
if (vertexList.contains(currNeighbor))
{
//find edge that connects to the current vertex
Object[] neighborEdges = aGraph.getEdges(currNeighbor, null, true, true, false, true);
Object connectingEdge = null;
for (int k = 0; k < neighborEdges.length; k++)
{
currEdge = neighborEdges[k];
if (aGraph.getTerminal(currEdge, true).equals(closestVertex)
|| aGraph.getTerminal(currEdge, false).equals(closestVertex))
{
connectingEdge = currEdge;
}
}
// check for new distance
int neighborIndex = vertexListStatic.indexOf(currNeighbor);
double oldDistance = distances[neighborIndex];
double currEdgeWeight;
currEdgeWeight = costFunction.getCost(new mxCellState(view, connectingEdge, null));
double newDistance = minDistance + currEdgeWeight;
//final part - updating the structure
if (newDistance < oldDistance)