当前位置: 首页 > 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.yayakq.cn/news/146501/

相关文章:

  • 乐山市规划和建设局网站霍林郭勒市建设局网站
  • 建设招聘网站淘宝上网站建设续费
  • 外贸网站建设推广公司价格没有公司可以注册网站吗
  • 招聘网站开发的目的与意义wordpress时间调用标签
  • 环保网站建设情况报告wordpress spam
  • 网站建站是什么网站怎么做电脑系统下载
  • h5电子商城网站开发广州公司注册代理机构哪家好
  • 邢台企业网站建设服务怎么把自己做的网站发布到网上
  • 专业建设网站哪个好wordpress3.8.1下载
  • 福州门户网站大连建站平台
  • 广州网站制作服务vps 需刷新几次才能打开网站
  • 互助平台网站建设金塔精神文明建设网站
  • 做网站设计需要学什么wordpress 酒店中文主题
  • 网站关键词推广优化界面设计案例分析
  • 合肥网站建设发布域名跟网站的区别吗
  • 杭州企业建站淘宝客网站建设教程
  • 网站管理员招聘自己做的网站很卡
  • 朋友说是做彩票网站运营维护外贸网站建设预算
  • 制作类网站90后做网站
  • 北京建设高端网站的合肥做淘宝网站推广
  • 网站的性能需求河北住房与城乡建设厅网站
  • 煤炭建设行业协会网站高端的网站设计费用
  • 江苏建设人才的网站夸克搜索网页版
  • 建立一个购物网站平台费用受欢迎的天津网站建设
  • 自己做交易网站wordpress 关闭ajax
  • 申请网站怎样申请网站开发都需要学什么
  • 电力网站建设方案投资公司属于什么行业
  • 为什么我有的网站打不开模板建站公司
  • 给个网站好人有好报2020免费河源北京网站建设
  • 怎么通过数据库做网站的登录网站推广方式主要通过