// Path: Exercises/E4/src/game/controllers/pacman/exercises/e4/graph/Link.java
// public class Link {
// 	
// 	public final Node n1;
// 	public final Node n2;
// 	
// 	public final MazeNode[] mazeNodes;
// 	
// 	public final int distance;
// 	
// 	public Link(Node n1, Node n2, MazeNode... mazeNodes) {
// 		this.n1 = n1;
// 		this.n2 = n2;
// 		this.mazeNodes = mazeNodes;
// 		distance = mazeNodes.length+1;
// 	}
// 	
// 	public Node getOtherEnd(Node node) {
// 		if (node == n1) return n2;
// 		if (node == n2) return n1;
// 		return null;
// 	}
// 	
// 	public void debugDrawLink(Game game, Color linkColor, Color nodeColor, boolean drawDistance) {
// 		GameView.addLines(game, linkColor, n1.index, mazeNodes[0].index);				
// 		int i = 0;
// 		int step = 4;
// 		for (i = step; i < mazeNodes.length-1; i += step) {
// 			GameView.addLines(game, linkColor, mazeNodes[i-step].index, mazeNodes[i].index);
// 		}				
// 		if (i >= mazeNodes.length) {
// 			GameView.addLines(game, linkColor, mazeNodes[i-step].index, mazeNodes[mazeNodes.length-1].index);
// 		}
// 		GameView.addLines(game, linkColor, mazeNodes[mazeNodes.length-1].index, n2.index);
// 		if (drawDistance) {
// 			GameView.addText(game, mazeNodes[mazeNodes.length/2].index, Color.YELLOW, String.valueOf(distance));			
// 		}
// 		GameView.addPoints(game, nodeColor, n1.index, n2.index);
// 	}
// 
// }
// 
// Path: Exercises/E4/src/game/controllers/pacman/exercises/e4/graph/Node.java
// public class Node {
// 	
// 	/**
// 	 * Unique index of the node.
// 	 */
// 	public final int index;
// 	
// 	/**
// 	 * Type of sub-node within the Pac-Man maze.
// 	 */
// 	public final NodeType type;
// 	
// 	/**
// 	 * Direction -> Link
// 	 * 
// 	 * Node that link is never stored for {@link Direction#NONE}.
// 	 */
// 	public Map<Direction, Link> links = new HashMap<Direction, Link>();
// 	
// 	public Node(int index, NodeType type) {
// 		this.index = index;
// 		this.type = type;
// 	}
// 	
// 	public Node(MazeNode node) {
// 		this.index = node.index;
// 		this.type = node.nodeType();
// 	}
// 	
// 	@Override
// 	public String toString() {
// 		return "Node[index=" + index + ",type=" + type + "]";
// 	}
// 	
// }


import java.util.Collection;
import game.controllers.pacman.exercises.e4.graph.Link;
import game.controllers.pacman.exercises.e4.graph.Node;
package game.controllers.pacman.exercises.e4.path;




public class Path {

	public Node[] path;
	
	public Path(Node... path) {
		this.path = path;
	}
	
	public Path(Collection<Node> path) {
		this.path = path.toArray(new Node[path.size()]);		
	}

	public void reverse() {
		Node[] pathReverse = new Node[path.length];
		for (int i = path.length - 1; i >= 0; --i) {
			pathReverse[path.length - 1 - i] = path[i];
		}
	    this.path = pathReverse;
	}

	public int computeCost() {
		int result = 0;
		for (int i = 1; i < path.length; ++i) {
			Node n1 = path[i-1];
			Node n2 = path[i];
// Path: Exercises/E4/src/game/controllers/pacman/exercises/e4/graph/Link.java
// public class Link {
// 	
// 	public final Node n1;
// 	public final Node n2;
// 	
// 	public final MazeNode[] mazeNodes;
// 	
// 	public final int distance;
// 	
// 	public Link(Node n1, Node n2, MazeNode... mazeNodes) {
// 		this.n1 = n1;
// 		this.n2 = n2;
// 		this.mazeNodes = mazeNodes;
// 		distance = mazeNodes.length+1;
// 	}
// 	
// 	public Node getOtherEnd(Node node) {
// 		if (node == n1) return n2;
// 		if (node == n2) return n1;
// 		return null;
// 	}
// 	
// 	public void debugDrawLink(Game game, Color linkColor, Color nodeColor, boolean drawDistance) {
// 		GameView.addLines(game, linkColor, n1.index, mazeNodes[0].index);				
// 		int i = 0;
// 		int step = 4;
// 		for (i = step; i < mazeNodes.length-1; i += step) {
// 			GameView.addLines(game, linkColor, mazeNodes[i-step].index, mazeNodes[i].index);
// 		}				
// 		if (i >= mazeNodes.length) {
// 			GameView.addLines(game, linkColor, mazeNodes[i-step].index, mazeNodes[mazeNodes.length-1].index);
// 		}
// 		GameView.addLines(game, linkColor, mazeNodes[mazeNodes.length-1].index, n2.index);
// 		if (drawDistance) {
// 			GameView.addText(game, mazeNodes[mazeNodes.length/2].index, Color.YELLOW, String.valueOf(distance));			
// 		}
// 		GameView.addPoints(game, nodeColor, n1.index, n2.index);
// 	}
// 
// }
// 
// Path: Exercises/E4/src/game/controllers/pacman/exercises/e4/graph/Node.java
// public class Node {
// 	
// 	/**
// 	 * Unique index of the node.
// 	 */
// 	public final int index;
// 	
// 	/**
// 	 * Type of sub-node within the Pac-Man maze.
// 	 */
// 	public final NodeType type;
// 	
// 	/**
// 	 * Direction -> Link
// 	 * 
// 	 * Node that link is never stored for {@link Direction#NONE}.
// 	 */
// 	public Map<Direction, Link> links = new HashMap<Direction, Link>();
// 	
// 	public Node(int index, NodeType type) {
// 		this.index = index;
// 		this.type = type;
// 	}
// 	
// 	public Node(MazeNode node) {
// 		this.index = node.index;
// 		this.type = node.nodeType();
// 	}
// 	
// 	@Override
// 	public String toString() {
// 		return "Node[index=" + index + ",type=" + type + "]";
// 	}
// 	
// }


// Path: Exercises/E4/src/game/controllers/pacman/exercises/e4/path/Path.java
import java.util.Collection;
import game.controllers.pacman.exercises.e4.graph.Link;
import game.controllers.pacman.exercises.e4.graph.Node;

package game.controllers.pacman.exercises.e4.path;




public class Path {

	public Node[] path;
	
	public Path(Node... path) {
		this.path = path;
	}
	
	public Path(Collection<Node> path) {
		this.path = path.toArray(new Node[path.size()]);		
	}

	public void reverse() {
		Node[] pathReverse = new Node[path.length];
		for (int i = path.length - 1; i >= 0; --i) {
			pathReverse[path.length - 1 - i] = path[i];
		}
	    this.path = pathReverse;
	}

	public int computeCost() {
		int result = 0;
		for (int i = 1; i < path.length; ++i) {
			Node n1 = path[i-1];
			Node n2 = path[i];
			for (Link link : n1.links.values()) {