// Copyright 2016, University of Freiburg, // Chair of Algorithms and Data Structures. // Authors: Patrick Brosi // _____________________________________________________________________________ template UndirGraph::UndirGraph() {} // _____________________________________________________________________________ template Node* UndirGraph::addNd(const N& pl) { return addNd(new UndirNode(pl)); } // _____________________________________________________________________________ template Node* UndirGraph::addNd() { return addNd(new UndirNode()); } // _____________________________________________________________________________ template Node* UndirGraph::addNd(UndirNode* n) { auto ins = Graph::getNds()->insert(n); return *ins.first; } // _____________________________________________________________________________ template Edge* UndirGraph::addEdg(Node* from, Node* to, const E& p) { Edge* e = Graph::getEdg(from, to); if (!e) { e = new Edge(from, to, p); from->addEdge(e); to->addEdge(e); } return e; } // _____________________________________________________________________________ template Node* UndirGraph::mergeNds(Node* a, Node* b) { for (auto e : a->getAdjListOut()) { if (e->getTo() != b) { addEdg(b, e->getTo(), e->pl()); } } for (auto e : a->getAdjListIn()) { if (e->getFrom() != b) { addEdg(e->getFrom(), b, e->pl()); } } UndirGraph::delNd(a); return b; }