本文整理汇总了C++中Corner::getWeight方法的典型用法代码示例。如果您正苦于以下问题:C++ Corner::getWeight方法的具体用法?C++ Corner::getWeight怎么用?C++ Corner::getWeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Corner
的用法示例。
在下文中一共展示了Corner::getWeight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: currentGraphType
string Graph::currentGraphType() {
int count = 0;
bool weighted = false;
bool directional = false;
bool pseudoGraph = false;
string graphTypes = "This graph is: ";
vector<Vertex *> vertexes = getVertexes();
for (vector<Vertex *>::iterator it = vertexes.begin(); it != vertexes.end(); it++) {
Vertex *vertex = *it;
vector<Adjacency *> adjacencies = vertex->getAdjacencies();
for (vector<Adjacency *>::iterator secondIt = adjacencies.begin(); secondIt != adjacencies.end(); secondIt++) {
Adjacency *adjacency = *secondIt;
Corner *corner = adjacency->getCorner();
Vertex *convergent = corner->getConvergent();
Vertex *divergent = corner->getDivergent();
if (!weighted && corner->getWeight() != -1) {
weighted = true;
}
if (!pseudoGraph && corner->isCycle()) {
pseudoGraph = true;
}
if (!directional && (convergent == nullptr || divergent == nullptr)) {
directional = true;
}
count++;
}
}
if (directional) {
graphTypes += " -> directional";
}
if (!directional && count != 0) {
graphTypes += " -> not directional";
}
if (weighted) {
graphTypes += " -> weighted";
}
if (pseudoGraph) {
graphTypes += " -> pseudoGraph";
}
if (count == 0) {
graphTypes += " -> null graph";
}
return graphTypes;
}
示例2: updateAllWeight
void Graph::updateAllWeight(Vertex *vertex) {
vector<Adjacency *> adjacencies = vertex->getAdjacencies();
for (vector<Adjacency *>::iterator it = adjacencies.begin(); it != adjacencies.end(); it++) {
Adjacency *adjacency = *it;
Corner *corner = adjacency->getCorner();
if (corner->getWeight() == -1) {
corner->setWeight(0);
}
}
}