Man, I hate this language. Just as much as everyone else does. Throwing that out there before I get attacked.

In school I was required to write in it for my CS class, and although google did good on solving most of my questions, on the last project I could not find anything for one part. To save others the same hassle, I decided I would post my (questionably? good) code up.

For those who don't know what Dijkstra's Algorithm is, here is some wiki: Dijkstra's algorithm - Wikipedia, the free encyclopedia .

* When I say no samples, I meant to say the only samples I could find was where the adjacency map was stored as a array, or the list itself was represented as a list of nodes. Neither I could do for my project. *

Code:
public int doDijkstras(String startVertexName, String endVertexName){
        HashMap<String, Integer> costPerNode = new HashMap<String, Integer>();
        ArrayList<String> processed = new ArrayList<String>(), inQueue = new ArrayList<String>();
        
        costPerNode.put(startVertexName, 0);
        Iterator<String> t = getAdjacentVertices(startVertexName).keySet().iterator();
        while(t.hasNext()){
            String hold = t.next();
            costPerNode.put(hold, getAdjacentCost(startVertexName, hold));
            inQueue.add(hold);
        }
        processed.add(startVertexName);

        while(!inQueue.isEmpty()){
            t = getAdjacentVertices(inQueue.get(0)).keySet().iterator();
            while(t.hasNext()){
                String hold = t.next();
                if(!processed.contains(hold))
                    inQueue.add(hold);
                if(costPerNode.get(hold) == null)
                    costPerNode.put(hold, costPerNode.get(inQueue.get(0)) + getAdjacentCost(inQueue.get(0), hold));
                else if(costPerNode.get(inQueue.get(0)) + getAdjacentCost(inQueue.get(0), hold) < costPerNode.get(hold)){
                    costPerNode.put(hold, costPerNode.get(inQueue.get(0)) + getAdjacentCost(inQueue.get(0), hold));
                    inQueue.add(hold);
                }
            }
            processed.add(inQueue.get(0));
            inQueue.remove(0);
        }
        
        processed.clear();
        inQueue.clear();
        
        if(costPerNode.get(endVertexName) != null)
            return costPerNode.get(endVertexName);
        else
            return 0;
    }
Helper methods:
Code:
private HashMap<String, HashMap<String,Integer>> adjacencyMap;   

    public Map<String, Integer> getAdjacentVertices(String vertexName){
        return adjacencyMap.get(vertexName);
    }

    public int getAdjacentCost(String startVertexName, String endVertexName){
        return adjacencyMap.get(startVertexName).get(endVertexName);
    }
Yeah, arguably I could have made the code more efficient and combined the loops, but I was far too lazy.