1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#include "vector"
#include "iostream"
#include "functional"
using namespace std;
class Edge
{
public:
int edgeID;
int edgeWeight;
Edge(int edge, int weight): edgeID(edge), edgeWeight(weight) { }
friend ostream& operator<<(ostream& out, const Edge& e)
{
cout << e.edgeID << " " << e.edgeWeight << endl;
return out;
}
};
class Node
{
public:
int nodeID;
int g, h, f;
vector<Edge> edgeList;
Node(int nID, int gCost, int hCost): nodeID(nID), g(gCost), h(hCost)
{
f = gCost + hCost;
}
Node(const Node& n)
{
f = n.g + n.h;
}
friend ostream& operator<<(ostream& out, const Node& n)
{
cout <<"ID: " << n.nodeID << " - F Cost: " << n.f << endl;
return out;
}
};
class Graph
{
public:
vector<Node> nodeList;
Graph()
{
nodeList.push_back(Node(1, 4, 0));
nodeList.push_back(Node(2, 3, 1));
Edge edge1(1, 1), edge2(2, 1);
nodeList[0].edgeList.push_back(edge1);
nodeList[1].edgeList.push_back(edge2);
}
};
|