当前位置: 首页 > 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.15wanjia.com/news/13129.html

相关文章:

  • java语言怎么做网站百度竞价开户流程
  • 各人可做的外贸网站seo主要优化哪些
  • 网站链接安全检测百度指数数据分析平台
  • 建立网站如何规划和实施建设网络营销和推广的方法
  • 宜春seo网站推广公司产品推广方案
  • 网站怎么换服务器郑州竞价托管公司哪家好
  • 贵阳个人做网站福建seo优化
  • 动态网站托管口碑营销的案例
  • 做一网站要学些什么个人怎么接外贸订单
  • 自己的网站怎么做下载链接东莞seo推广机构帖子
  • 网站建设毕业答辩问题广告信息发布平台
  • 昆明建网站公司网络销售适合什么人做
  • 陕西建设注册中心网站成都排名推广
  • 哪个网站做欧洲旅游攻略好服务器ip域名解析
  • 艾科斗少儿编程加盟免费的电脑优化软件
  • 新人做网站盈利b2b免费外链发布
  • wordpress启动广告seo点击排名器
  • 物流企业网站建设自媒体135网站免费下载安装
  • 做电影网站要多少钱设计网络营销方案
  • wordpress自动 插件优化大师手机版
  • seo优化网站建设哪家好网站优化关键词排名
  • 中英文网站建设需要懂英语吗房管局备案查询网站
  • 哈尔滨站建站时间关键词分为哪三类
  • 泉州市做网站优化口碑营销的步骤
  • 内蒙古建设工程交易中心网站百度客服中心人工电话
  • 群辉nas怎么做网站seo实战论坛
  • 低价网站设计seo免费入门教程
  • 徐州网站开发服务seo在线网站推广
  • 武汉做网站的公司软文什么意思
  • 网站做跳转的要求百度网站app下载