当前位置: 首页 > news >正文

做的好看的外国网站济南疫情最新消息

做的好看的外国网站,济南疫情最新消息,濮阳家电网站建设,深圳网络营销招聘way&#xff1a;找入度为0的节点删除&#xff0c;减少其他节点的入度&#xff0c;继续找入度为0的节点&#xff0c;直到删除完所有的图节点。&#xff08;遍历node的neighbors就能得到neighbors的入度信息&#xff09; #include<iostream> #include<vector> #incl…

 way:找入度为0的节点删除,减少其他节点的入度,继续找入度为0的节点,直到删除完所有的图节点。(遍历node的neighbors就能得到neighbors的入度信息)

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;//边结构的描述
class Edge
{
public://边的起始节点Node *from;//边的终点节点Node *to;//边的权重int weight;
public:Edge(Node *from, Node *to, int weight){this->from = from;this->to = to;this->weight = weight;}
};//点结构的描述
class Node
{
public://编号值int value;//入度int in;//出度int out;//邻接的点vector<Node*> nexts;//邻接的边vector<Edge*> edges;
public:Node(){}Node(int value){this->value = value;in = 0;out = 0;}
};//图结构的描述
class Graph
{
public:map<int, Node*> nodes;set<Edge*> edges;Graph(){}
};//利用边结构描述的图来构建图结构
//[0,7,5]   [from,to,weight]
//[0,1,3]   [from,to,weight]
Graph* createGraph(vector<vector<int>> matrix)
{Graph *graph = new Graph();int m = matrix.size();for(int i=0; i<m; i++){int from = matrix[i][0];int to = matrix[i][1];int weight = matrix[i][2];//将起点结构放到图里面if(!graph->nodes.count(from)){Node *fromNode =new Node(from);graph->nodes[from] = fromNode;}//将终点结构放到图里面if(!graph->nodes.count(to)){Node *toNode=new Node(to);graph->nodes[to] = toNode;}//将起点和终点的边结构也放到图里面(点可能已经存在过,边一定是新的)Node *fromNode = graph->nodes[from];Node *toNode = graph->nodes[to];Edge *newEdge = new Edge(fromNode, toNode, weight);fromNode->nexts.push_back(toNode);fromNode->edges.push_back(newEdge);fromNode->out++;toNode->in++;graph->edges.insert(newEdge);}return graph;
}vector<Node*> topSort(Graph *graph)
{//收集节点入度映射,将0入度放入que中map<Node*,int>indegreeMap;queue<Node*>zeroQue;for(auto pa:graph->nodes){indegreeMap[pa.second]=pa.second->in;if(indegreeMap[pa.second]==0){zeroQue.push(pa.second);}}vector<Node*>result;//开始按入度为0删除节点,同时减少其他节点入度,删除入度为0...while(!zeroQue.empty()){Node *cur=zeroQue.front();zeroQue.pop();result.push_back(cur);for(auto next: cur->nexts){indegreeMap[next]=indegreeMap[next]-1;if(indegreeMap[next]==0){zeroQue.push(next);}}}return result;
}

http://www.dinnco.com/news/25858.html

相关文章:

  • 大型网站服务器多少钱网站制作平台
  • 做报废厂房网站怎么做网上怎么找人去推广广告
  • 企业查询系统官网河北seo还有前景吗
  • 西安手机网站制作的公司哪个浏览器看黄页最快夸克浏览器
  • 建立网站的英文互站网
  • 微信做淘宝优惠券但网站是怎么建设但问卷调查网站
  • 在虚拟机做网站整站优化代理
  • 服装网站建设方案旅游营销推广方案
  • 名片在哪个网站可以做深圳百度推广竞价托管
  • 最好的网站开发公司电话外贸营销型网站
  • 网站开发外包维护合同郑州seo优化外包
  • win7做系统网站哪个好新网
  • 职业生涯规划大赛演讲稿东莞百度seo排名
  • 网站正在维护中html百度认证考试
  • 网站 建设 步骤是百度识图在线识别
  • 做网站的时候怎么照片路径游戏挂机赚钱一小时20
  • 昆明建网站公司廊坊seo
  • 内部优惠券网站建站cms
  • 增城企业网站建设友情链接2598
  • 票务网站开发端口百度关键词seo推广
  • 免费自建网站工具农产品推广方案
  • 开公司怎么找客户seo工具查询
  • 网站的建设价格建立个人网站
  • 武昌有专业做网站如何免费推广自己的产品
  • 平顶山市住房和城乡建设局网站百度广告投放价格
  • 手机宣传网站5118站长网站
  • wordpress文章页折叠互联网优化是什么意思
  • 做网站编辑工作累吗中国站长之家
  • 网站建设与管理知识点乐事薯片软文推广
  • c 网站开发 调试网页自助建站