Пример #1
0
double WDGraph<Comparable>::GetWeightBetween(const Comparable &lhs, const Comparable &rhs) const {
    if (ContainsVertex(lhs) && ContainsVertex(rhs)) {
        if (ContainsEdge(lhs, rhs))
            return vertices_.find(lhs)->second.adj_l.find(rhs)->second;
        else
            return -1;
    } else
        return -1;
}
Пример #2
0
 bool Check(const GraphComponent<Graph> &component) const {
     for (auto it = edges_of_interest_.begin();
             it != edges_of_interest_.end(); ++it) {
         if (ContainsEdge(component, *it)) {
             return true;
         }
     }
     return false;
 }
Пример #3
0
bool WDGraph<Comparable>::AddEdge(const Comparable &lhs, const Comparable &rhs, double weight) {
    if (ContainsEdge(lhs, rhs))
        return false;
    else {
        if (ContainsVertex(lhs) && ContainsVertex(rhs)) {
            auto fetchVertex = vertices_.find(lhs);
            fetchVertex->second.adj_l.insert(std::pair<Comparable, double>(rhs, weight));
            return true;
        } else
            return false;
    }
}