package edu.cmu.cs.l3.graph;

import java.util.*;

public class Vertex {

    public Vertex() {
    }

    public void setOwner(Graph graph, int id) {
        m_graph = graph;
        m_id = id;
    }

    public Graph getOwner() {
        return m_graph;
    }

    public int getID() {
        return m_id;
    }

    public int getDegree(int type) throws GraphException {

        if (m_graph == null) {
            throw new GraphException("Method called on Vertex with no-owner");
        }

        return m_graph.getDegree(this,type);
    }

    public List getAdjacents() throws GraphException {
        if (m_graph == null) {
           throw new GraphException("Method called on Vertex with no-owner");
       }

        return m_graph.getAdjacents(this);
    }

    public boolean isAdjacent(Vertex v) throws GraphException {
        if (m_graph == null) {
            throw new GraphException("Method called on Vertex with no-owner");
        }

        return m_graph.isAdjacent(this,v);

    }

    public boolean auxIsMarked() {
        return m_mark;
    }

    public void deadMark() {
        m_deadmark = true;
    }

    public void deadUnmark() {
        m_deadmark = false;
    }

    public boolean deadIsMarked() {
        return m_deadmark;
    }

    public void auxMark() {
        m_mark = true;
    }

    public void auxUnmark() {
        m_mark = false;
    }

    public String toString() {
        return "V:" + m_id;
    }

    public List getInList() {
        return m_inlist;
    }

    public List getOutList() {
        return m_outlist;
    }

    private Graph m_graph;
    private int m_id;
    private boolean m_mark=false, m_deadmark=false;
    private List m_inlist = new ArrayList(),m_outlist = new ArrayList();
}