⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c13p737.txt

📁 Data Abstraction & Problem Solving with C++源码
💻 TXT
字号:
// ****************************************************// Implementation file Graph.cpp // An adjacency list representation of an undirected,// weighted graph.  // ****************************************************#include "Graph.h"Graph::Graph(int n){   adjList.assign(n);   numVertices = n;}  // end constructorint Graph::getNumVertices() const{   return numVertices;}  // end getNumVerticesint Graph::getNumEdges() const{     return numEdges;}  // end getNumEdgesint Graph::getWeight(Edge e) const{   return e.weight;}  // end getWeightvoid Graph::add(Edge e){   int v = e.v,       w = e.w,       weight = e.weight;   adjList[v].insert(make_pair(w, weight));   adjList[w].insert(make_pair(v, weight));   numEdges++;}  // end addvoid Graph::remove(Edge e){   int v = e.v,       w = e.w,        weight = e.weight;   adjList[e.v].erase(w);   adjList[e.w].erase(v);   numEdges--;}  // end removemap<int,int>::iterator Graph::findEdge(int v, int w){   map<int,int> m = adjList[v];   map<int,int>::iterator iter = m.find(w);	   return iter;}  // end findEdge

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -