#include "edgelist.h" bool edgelist::addEdge(const char *src, const char *dest, const double weight, vertexlist& vl, vector >& adjList, vector >& adjMatrix, const bool directed) { int srcNdx = vl.findVertex(src); int destNdx = vl.findVertex(dest); if (srcNdx==-1) srcNdx = vl.addVertex(src, adjList, adjMatrix); if (destNdx==-1) destNdx = vl.addVertex(dest, adjList, adjMatrix); edge e(srcNdx, destNdx, weight); el.push_back(e); tovert t(e.to, e.weight); adjList[e.from].push_back(t); adjMatrix[e.from][e.to] = e.weight; if (!directed) { tovert t2(e.from, e.weight); adjList[e.to].push_back(t2); adjMatrix[e.to][e.from] = e.weight; } return true; } unsigned int edgelist::size() const { return el.size(); } const edge edgelist::getEdge(const int n) const { if ((unsigned int) n > size()-1) throw "Error: Invalid edge requested"; else return el[n]; }