您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ BFS函数代码示例

51自学网 2021-06-01 19:49:41
  C++
这篇教程C++ BFS函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中BFS函数的典型用法代码示例。如果您正苦于以下问题:C++ BFS函数的具体用法?C++ BFS怎么用?C++ BFS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了BFS函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: BFS

 void BFS(vector<vector<TreeNode *>> &cash, vector<TreeNode *> level) {     int len = level.size();     if (len == 0) return;     vector<TreeNode *> childs;     for (int i = 0; i < len; ++i) {         if (level[i]->left) childs.push_back(level[i]->left);         if (level[i]->right) childs.push_back(level[i]->right);     }     if (childs.size() > 0) cash.push_back(childs);     BFS(cash, childs); }
开发者ID:ygxqqx,项目名称:LeetCode,代码行数:11,


示例2: BFSTraversal

void BFSTraversal(graph *g){	int visited[g->v];	for(int i=0;i<g->v;i++)	  visited[i]=0;	for(int i=0;i<g->v;i++)	{		if(!visited[i])		  BFS(g,i,visited);	} }
开发者ID:arjunvijayvargiya,项目名称:DataStructureAndAlgorithmNK,代码行数:11,


示例3: BFS_All

void BFS_All(AdjList *a){    int i;    for(i=0;i<a->vexnum;i++)    {        if(!a->vertex[i].sign)        {            BFS(a,i);        }    }}
开发者ID:dreamer2018,项目名称:DataStructure,代码行数:11,


示例4: LOG4CXX_DEBUG

//gap fillingvoid GapFiller::fill() {    LOG4CXX_DEBUG(logger, "Begin Gap Filling ... ");    size_t num_failed_gaps = 0, num_uniq_gaps = 0, num_multi_gaps = 0, num_overlaps = 0;	for (size_t i = 0; i < _scaffolds.size(); ++i) {		if (_scaffolds[i].contigs.size() <= 1) { // no gaps			continue;		}        Component::ContigIdList contigs = _scaffolds[i].contigs;		for (size_t j = 1; j < contigs.size(); ++j) {			int left_index = contigs[j - 1];			int right_index = contigs[j];            const std::string& lsequence = _uniq_graph._indexer[left_index].seq;            const std::string& rsequence = _uniq_graph._indexer[right_index].seq;            std::string suffix = lsequence.substr(lsequence.length() - (_K - 1), _K - 1);            std::string prefix = rsequence.substr(0, _K - 1);			int overlap = alignment(suffix, prefix);            int gap = _scaffolds[i].gaps[j - 1];			if (overlap >= _OVERLAP) {                _gapinfo_tbl[std::make_pair(i, j)] = GapInfo(-1, -overlap);                ++num_overlaps;			} else if (gap > _INSERT_SIZE + 3*_DELTA) {                _gapinfo_tbl[std::make_pair(i, j)] = GapInfo(-1, gap);                ++num_failed_gaps;            } else {                try {                    GapInfo gapinfo(-1, gap);                    BFS(left_index, right_index, gap, &gapinfo);                    _gapinfo_tbl[std::make_pair(i, j)] = gapinfo;                    if (gapinfo.pathlist.empty()) {                        ++num_failed_gaps;                    } else if (gapinfo.pathlist.size() == 1) {                        ++num_uniq_gaps;                    } else {                        ++num_multi_gaps;                    }                } catch(std::bad_alloc) {                    LOG4CXX_WARN(logger, "BFS is too memory-intensive, ignoring...");                    _gapinfo_tbl[std::make_pair(i, j)] = GapInfo(-1, -gap);                    ++num_failed_gaps;                }            }		}	}	LOG4CXX_DEBUG(logger, boost::format("The number of gaps = %d") % _gapinfo_tbl.size());	LOG4CXX_DEBUG(logger, boost::format("The number of failed gaps = %d") % num_failed_gaps);	LOG4CXX_DEBUG(logger, boost::format("The number of unique gaps = %d") % num_uniq_gaps);	LOG4CXX_DEBUG(logger, boost::format("The number of multiple gaps = %d") % num_multi_gaps);	LOG4CXX_DEBUG(logger, boost::format("The number of overlap = %d") % num_overlaps);}
开发者ID:zhujianwei31415,项目名称:ARCS,代码行数:54,


示例5: numIslands

 int numIslands(vector<vector<char>>& grid) {     const int m = grid.size(), n = grid[0].size();     int ret = 0;     for(int i = 0; i < m; ++i)     	for(int j = 0; j < n; ++j) {     		if(1 == grid[i][j]) {     			++ret;     			BFS(grid, i, j);     		}     	} 	return ret; }
开发者ID:futureCoder,项目名称:algorithms,代码行数:12,


示例6: main

task main(){	Queue Q;	CreateEmpty(&Q);	int color = searchSpot();	if(color==green) {		stepAhead(220);		turn(right,20);		cekSimpang(&Q);	}	BFS(first,&Q);}
开发者ID:sorlawan,项目名称:routeplanningEV3,代码行数:12,


示例7: isap

int isap(int st, int ed, int N) {    BFS(st, ed);    memcpy(cur, head, sizeof(head));    int top = 0;    int u = st;    int ans = 0;    while(dep[st] < N) {        if(u == ed) {            int Min = INF;            int inser;            for(int i = 0; i < top; i++)                if(Min > edge[S[i]].cap - edge[S[i]].flow) {                    Min = edge[S[i]].cap - edge[S[i]].flow;                    inser = i;                }            for(int i = 0; i < top; i++) {                edge[S[i]].flow += Min;                edge[S[i] ^ 1].flow -= Min;            }            ans += Min;            top = inser;            u = edge[S[top] ^ 1].to;            continue;        }        bool flag = false;        int v;        for(int i = cur[u]; i != -1; i = edge[i].next) {            v = edge[i].to;            if(edge[i].cap - edge[i].flow && dep[v] + 1 == dep[u]) {                flag = true;                cur[u] = i;                break;            }        }        if(flag) {            S[top++] = cur[u];            u = v;            continue;        }        int Min = N;        for(int i = head[u]; i != -1; i = edge[i].next)            if(edge[i].cap - edge[i].flow && dep[edge[i].to] < Min) {                Min = dep[edge[i].to];                cur[u] = i;            }        gap[dep[u]]--;        if(!gap[dep[u]])return ans;        dep[u] = Min + 1;        gap[dep[u]]++;        if(u != st) u = edge[S[--top] ^ 1].to;    }    return ans;}
开发者ID:ToRapture,项目名称:ACM-Template,代码行数:53,


示例8: main

int main(){	//Algorithms::testQuickSort();	//Algorithms::testCountingSort();	//Algorithms::lis();	//Algorithms::editDistance();	//Algorithms::pocket();	//Algorithms::uniquePocket();	DFS();	BFS();	return 0;}
开发者ID:durkmurder,项目名称:fancy-programming,代码行数:12,


示例9: main

int main(){        LinkGraph **g = Create_Graph_List();    Input_Graph_Edge(g);    Print_Graph_List(g);    BFS(g,0);    return 0;}
开发者ID:TaliensCode,项目名称:GraphList,代码行数:12,


示例10: ExcluirAresta

    static GRA_tpCondRet ExcluirAresta (GRA_tppGrafo grafo, tpVertice* v, tpVertice* u) {        RemoverAresta(v, u);//mexe só em v, ou deveria               RemoverAresta(u, v);        //BFS pra detectar se é necessário gerar nova componente.        if (BFS(v,u) != 1) { //Est
C++ BFS_SB函数代码示例
C++ BFD_ASSERT函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。