package com.dragonheart.dijkstra;

import java.util.ArrayList;
import java.util.List;

public class DijkstraGraph {
	private ArrayList<Edge> listOfEdges;
	private ArrayList<Point> listOfPoints, sourcePoints;

	public DijkstraGraph() {
		this.listOfEdges = new ArrayList<Edge>();
		this.listOfPoints = new ArrayList<Point>();
		this.sourcePoints = new ArrayList<Point>();
	}

	public void addPoint(Point point) {
		listOfPoints.add(point);
	}

	public void addEdge(Edge edge) {
		listOfEdges.add(edge);
	}

	public void addSource(Point point, Double cost) {
		if(listOfPoints.contains(point)) {
			point.aggregateCost = cost;
			sourcePoints.add(point);
		}
	}

	public void addSources(List<Point> points, Double cost) {
		for(Point point : points) {
			addSource(point, cost);
		}
	}

	public void setSource(Point point, Double cost) {
		sourcePoints = new ArrayList<Point>();
		addSource(point, cost);
	}

	public void setSources(List<Point> points, Double cost) {
		sourcePoints = new ArrayList<Point>();
		addSources(points, cost);
	}

	public boolean processGraph() {
		if(sourcePoints.isEmpty()) {
			return false;
		}
		
		return true;
	}
}

@@ -1119,16 +1119,171 @@
 ;%0A%09%09%7D%0A%09%09
+for(Point point : listOfPoints) %7B%0A%09%09%09point.resetVisited();%0A%09%09%09point.aggregateCost = null;%0A%09%09%09point.edgeWithLowestCost = null;%0A%09%09%7D%0A%09%09Point.TotalVisited = 0;
 %0A%09%09retur

reset not needed as it is now would only be called here