本文整理汇总了C++中Graph::E方法的典型用法代码示例。如果您正苦于以下问题:C++ Graph::E方法的具体用法?C++ Graph::E怎么用?C++ Graph::E使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph::E方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: route
void Evnav::route(EvnavRequest &req, QJsonObject &json)
{
Trip trip;
Graph g;
VertexId srcId = -1;
VertexId dstId = -2;
double SOC_dyn = req.m_SOC_max - req.m_SOC_min;
double batt_act = req.m_battery * req.m_SOC_act; // kWh
double batt_dyn = req.m_battery * SOC_dyn;
if (computeTrip(req.m_src, req.m_dst, trip) == Status::Ok) {
double e = computeEnergy(trip, req.m_efficiency);
double e_otw = 0; // kWh
if (e > batt_act) {
e_otw = e - batt_act;
}
qDebug() << "energy required : " << e << "kWh";
qDebug() << "energy start : " << batt_act << "kWh";
qDebug() << "energy on the way: " << e_otw << "kWh";
if (e < batt_act) {
qDebug() << "reaching destination without charging";
// FIXME: collect result processing
json["code"] = "Ok";
json["message"] = "reachable";
QJsonObject summary;
summary["distance"] = trip.dist_m;
summary["duration"] = trip.time_s;
summary["energy"] = e;
summary["driving_duration"] = trip.time_s;
summary["charging_duration"] = 0;
summary["charging_cost"] = 0;
json["route_summary"] = summary;
json["charging_steps"] = QJsonArray{};
return;
} else {
int min_stops = std::ceil(e_otw / batt_dyn);
double charging_time = computeChargingTime(e_otw, req.m_power_avg);
qDebug() << "charging min_stops:" << min_stops;
qDebug() << "charging min_time :" << formatTime(charging_time);
}
}
makeGraph(g, req, srcId, dstId);
qDebug() << "graph size:" << g.E();
// TODO: write the graph as Json
ShortestPath sp(g, srcId);
if (sp.hasPathTo(dstId)) {
QVector<Edge> path = sp.pathTo(dstId).toVector();
write(path, json);
} else {
json["code"] = "Ok";
json["message"] = "unreachable";
qDebug() << "cannot reach destination with this electric car";
}
}