/**********************************
 * Assignment 5: Pacman
 * Date: 5/5/2006
 *
 * Jenna Holloway: jh382, 563324
 * Benji Shultz: bas67, 1786511
 **********************************/
/***************************
 * The node (vertex) class
 */

package graph;

import java.awt.Point;
import java.awt.geom.Point2D;
import java.util.Iterator;
import java.util.Vector;

public class Node {
    int id;  // a unique non-negative identifier, assigned by the graph
    int x, y;  // coordinate of the node on the x-y plane
    public Vector<Node> neighbors;  // neighbors of the node\
    int pathid=-1;

    /* Constructors
     */
    public Node(int _id, int _x, int _y) {
        id = _id;
        x = _x;
        y = _y;
        neighbors = new Vector<Node>();
    }
    public Node(Point2D p2d){
    	this(0,(int)p2d.getX(),(int)p2d.getY());
    }
    

    /* Add a neighbor to the node
     */
    public void addNeighbor(Node v) {
        neighbors.add(v);
    }

    /* Return an iterator of neighboring nodes
     */
    public Iterator<Node> getNeighbors() {
        return neighbors.iterator();
    }
    
    //comparison method
    public boolean equals(Node node){
      return this.x==node.x&&this.y==node.y;
    }
    //euclidean distance calculation
    public double distance(Node n){
      return Math.sqrt(Math.pow(x-n.x,2)+Math.pow(y-n.y,2));
    }
    
    /* Access methods
     */
 public int getId() {
  return id;
 }
 public int getX(){
	 return x;
 }
 public int getY(){
	 return y;
 }
    public Point2D getCoordinates(){
  return new Point.Double(x, y);
 }
}