示例#1
0
int ShortestPathDAG::Memo(Vertex* s, Vertex* d)
{
	if (s == d)
		return 0;

	if (d->ShortestPathWeight() != Vertex::NOT_CALCULATED)
		return d->ShortestPathWeight();

	int shortestPath = INT_MAX;

	auto& edgeToMeList = d->EdgeToMeList();
	for (auto& edgeToMe = edgeToMeList.begin(); edgeToMe != edgeToMeList.end(); ++edgeToMe)
	{
		int res = Memo(s, (*edgeToMe)->StartV()) + (*edgeToMe)->Val();
		
		shortestPath = min(res, shortestPath);
	}

	d->ShortestPathWeight(shortestPath);

	return shortestPath;
}
Product::Memo Product::pod_pack() const { return Memo(id,productID,title,price, productType);}
Review::Memo Review::pod_pack() const {
	std::list<std::string> snt;
	for (auto &s : sentences) snt.push_back(std::string(s));
	return Memo(id,summary,snt,score,time,reviewer->pod_pack(),help,product->pod_pack(),text);
}