/**
*	\file Vertex.h
*	\brief	Class representing a vertex.
*	\author	Matteo Petris
*	\date	december 2021
*/
#ifndef VERTEX_H
#define VERTEX_H

#include "Header.h"

/**
*	\class Vertex.
*	\brief	Class a vertex in the compatibility graph
*/
class Vertex {

protected:

	int id;										/**< The id.*/
	char type;									/**< type='A' means altruistic donor, ='I' means incompatible pair, ='D' means dummy vertex*/
	int word;									/**< bit word*/
	int bitKey;									/**< bit key*/
	unordered_map<int, int> inGoingArcs;		/**< key=i, where (i,this) is an arc, value = weight of (i,this)*/
	unordered_map<int, int> outGoingArcs;		/**< key=i, where (this,i) is an arc, value = weight of (this,i)*/
	vector<int> extendedPredecessors;
	vector<int> ngSet;							/**< store the subset encoded as bit keys*/

public:
	
	//CONSTRUCTORS (default, parametrized, copy)
	Vertex();
	Vertex(const int& id, const char& type);
	Vertex(const Vertex& v);

	//DESTRUCTOR
	~Vertex();

	//OPERATORS OVERLOADING (assignment, equality, not equal to)
	Vertex& operator=(const Vertex& v);
	friend bool operator==(const Vertex& v1, const Vertex& v2);
	friend bool operator!=(const Vertex& v1, const Vertex& v2);

	//METHODS
	void addInGoingArc(const int& id, const int& weight);
	void addOutGoingArc(const int& id, const int& weight);
	void removeInGoingArc(const int& id);
	void removeOutGoingArc(const int& id);
	void addExtendedPredecessor(const int& id);
	void initializeNgSet(const int& wordsNumber);
	void addNgNeighbour(const int& word, const int& bitKey);

	//GET METHODS
	const int& getId() const;
	const char& getType() const;
	const int& getWord() const;
	const int& getBitKey() const;
	const unordered_map<int, int>& getInGoingArcs() const;
	const unordered_map<int, int>& getOutGoingArcs() const;
	const vector<int>& getExtendedPredecessors() const;
	const vector<int>& getNgSet() const;

	//SET METHODS
	void setWord(const int& word);
	void setBitKey(const int& bit);

	/**
	*	\brief	Converts the vertex into a string containing information related to it.
	*	Useful to have the vertex in an output like a text file or console.
	*	\return converted_vertex : string
	*/
	const string toString(const bool& printAdjacencyLists) const;

};

#endif //VERTEX_H