
#include "graph.hpp"

//construtor
graphfind::graphfind(const graph * map, int size)
{
    init();
    _mapSize = size;
    _map = map;
}

//stack all route
stack<node> * graphfind::getAllNeighbor(int from)
{
    //initialisation
    stack<node> * neighbor = new stack<node>;                        //pile de chemin
    node tmp;
    tmp.dist=0;
    //for all node in graph
    for (int i=0;i<_mapSize;i++)
        if (_map[i].from == from)
        {
            tmp.index = _map[i].to;
            tmp.parent = _map[i].from;
            tmp.cost = _map[i].cost;
            neighbor->push(tmp);
        }
        else if(_map[i].to == from)
        {
            tmp.index = _map[i].from;
            tmp.parent = _map[i].to;
            tmp.cost = _map[i].cost;
            neighbor->push(tmp);
        }
    return neighbor;
}
