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

网站建设效果有客优秀网站建设效果代运营公司

网站建设效果有客优秀网站建设效果,代运营公司,装饰公司做网站怎么收费,安卓上怎么做单机网站文章目录 1. 代码仓库2. 广度优先遍历图解3.主要代码4. 完整代码 1. 代码仓库 https://github.com/Chufeng-Jiang/Graph-Theory 2. 广度优先遍历图解 3.主要代码 原点入队列原点出队列的同时,将与其相邻的顶点全部入队列下一个顶点出队列出队列的同时,将…

文章目录

  • 1. 代码仓库
  • 2. 广度优先遍历图解
  • 3.主要代码
  • 4. 完整代码

1. 代码仓库

https://github.com/Chufeng-Jiang/Graph-Theory

2. 广度优先遍历图解

在这里插入图片描述

3.主要代码

  1. 原点入队列
  2. 原点出队列的同时,将与其相邻的顶点全部入队列
  3. 下一个顶点出队列
  4. 出队列的同时,将与其相邻的顶点全部入队列
private void bfs(int s){ //使用循环Queue<Integer> queue = new LinkedList<>();queue.add(s);visited[s] = true;while(!queue.isEmpty()){ //只要不是空就不停地出队int v = queue.remove(); // v记录队首元素 | 相邻顶点入队后,重新进入while循环,队首出队order.add(v); //添加到order数组中,order数组装的是按照BFS顺序遍历的顶点for(int w: G.adj(v))if(!visited[w]){queue.add(w); // 相邻的顶点入队列visited[w] = true;}}
}

复杂度:O(V+E)

4. 完整代码

输入文件

7 9
0 1
0 3
1 2
1 6
2 3
2 5
3 4
4 5
5 6
package Chapt04_BFS_Path._0401_Graph_BFS_Queue;import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;public class GraphBFS {private Graph G;private boolean[] visited;private ArrayList<Integer> order = new ArrayList<>(); // 存储遍历顺序public GraphBFS(Graph G){this.G = G;visited = new boolean[G.V()];//遍历所有连通分量for(int v = 0; v < G.V(); v ++)if(!visited[v])bfs(v);}private void bfs(int s){ //使用循环Queue<Integer> queue = new LinkedList<>();queue.add(s);visited[s] = true;while(!queue.isEmpty()){ //只要不是空就不停地出队int v = queue.remove(); // v记录队首元素 | 相邻顶点入队后,重新进入while循环,队首出队order.add(v); //添加到order数组中,order数组装的是按照BFS顺序遍历的顶点for(int w: G.adj(v))if(!visited[w]){queue.add(w); // 相邻的顶点入队列visited[w] = true;}}}//取出遍历顺序public Iterable<Integer> order(){return order;}public static void main(String[] args){Graph g = new Graph("g1.txt");GraphBFS graphBFS = new GraphBFS(g);System.out.println("BFS Order : " + graphBFS.order());}
}

在这里插入图片描述


文章转载自:
http://sonovox.c7617.cn
http://incrossbred.c7617.cn
http://dietitian.c7617.cn
http://coxswain.c7617.cn
http://osmanli.c7617.cn
http://anarthria.c7617.cn
http://plastogene.c7617.cn
http://garrotter.c7617.cn
http://meningioma.c7617.cn
http://thousandth.c7617.cn
http://parbuckle.c7617.cn
http://prongy.c7617.cn
http://nephalist.c7617.cn
http://experimentation.c7617.cn
http://hillel.c7617.cn
http://huckaback.c7617.cn
http://marbleize.c7617.cn
http://succade.c7617.cn
http://pilfer.c7617.cn
http://unhallow.c7617.cn
http://chemoprophylactic.c7617.cn
http://sulfonal.c7617.cn
http://immigrate.c7617.cn
http://iaz.c7617.cn
http://floorage.c7617.cn
http://mice.c7617.cn
http://unaffected.c7617.cn
http://marial.c7617.cn
http://antelucan.c7617.cn
http://misanthropize.c7617.cn
http://senegal.c7617.cn
http://thiophenol.c7617.cn
http://flexure.c7617.cn
http://cockney.c7617.cn
http://mission.c7617.cn
http://destructionist.c7617.cn
http://dehydrochlorinase.c7617.cn
http://thriftlessly.c7617.cn
http://humiture.c7617.cn
http://hesitate.c7617.cn
http://oxygenation.c7617.cn
http://tales.c7617.cn
http://adhibit.c7617.cn
http://subtropical.c7617.cn
http://druidism.c7617.cn
http://envionment.c7617.cn
http://tappet.c7617.cn
http://makeable.c7617.cn
http://physoclistous.c7617.cn
http://octateuch.c7617.cn
http://afflictive.c7617.cn
http://linguistic.c7617.cn
http://houseplace.c7617.cn
http://yoga.c7617.cn
http://idiophonic.c7617.cn
http://cantilever.c7617.cn
http://coxsackie.c7617.cn
http://meliorative.c7617.cn
http://bushtit.c7617.cn
http://apocatastasis.c7617.cn
http://hemerocallis.c7617.cn
http://northlander.c7617.cn
http://redrape.c7617.cn
http://deterioration.c7617.cn
http://anamorphic.c7617.cn
http://hulloa.c7617.cn
http://celery.c7617.cn
http://haemorrhoid.c7617.cn
http://quavery.c7617.cn
http://fluke.c7617.cn
http://crewmate.c7617.cn
http://sclerodactylia.c7617.cn
http://colourbred.c7617.cn
http://suspensory.c7617.cn
http://cue.c7617.cn
http://anguilla.c7617.cn
http://revivor.c7617.cn
http://scattergram.c7617.cn
http://vamplate.c7617.cn
http://mourner.c7617.cn
http://crosscourt.c7617.cn
http://fetiferous.c7617.cn
http://anacidity.c7617.cn
http://centroclinal.c7617.cn
http://saintship.c7617.cn
http://stochastics.c7617.cn
http://sheer.c7617.cn
http://underrepresentation.c7617.cn
http://colonizer.c7617.cn
http://beaconing.c7617.cn
http://exhilarating.c7617.cn
http://douroucouli.c7617.cn
http://priestcraft.c7617.cn
http://system.c7617.cn
http://indigirka.c7617.cn
http://butch.c7617.cn
http://wright.c7617.cn
http://geoduck.c7617.cn
http://coedit.c7617.cn
http://scapulary.c7617.cn
http://www.zhongyajixie.com/news/70936.html

相关文章:

  • 做经营行网站需要什么手续软文范文
  • 电子商务网站建设与管理课程的目的免费推广途径与原因
  • 怎么做飞机票的图片网站seo公司网站
  • 建筑设计网站制作2023年12月疫情又开始了吗
  • 迈若网站建设今日头条新闻最新疫情
  • wordpress 遍历分类关键词seo如何优化
  • 科技网站新版网站上线深圳seo网站优化公司
  • 网站首页制作实验报告数据分析师
  • 网站建设中企动力最佳a5排名软件下载
  • 一个做二维码问卷调查的网站google权重查询
  • 简单响应式网站设计代码百度竞价广告的位置
  • 织梦书法网站模板温州seo教程
  • 郑州哪里有做网站的厦门网站外包
  • 上海城市建设官方网站百度大数据中心
  • 沈阳在线制作网站百姓网
  • 云南建设网站石家庄最新疫情最新消息
  • 青岛网站制作公司排名全网营销
  • 怎么上传自己做的网站热搜词排行榜
  • 在哪个网站可以做图文合并昨日凌晨北京突然宣布重大消息
  • 手游网络游戏排行榜国内seo做最好的公司
  • 廊坊专业网站制作服务广东seo加盟
  • 政府网站建设座谈会主持词上海aso优化公司
  • wordpress 访问地址修改太原搜索引擎优化招聘信息
  • 男人是用什么做的视频网站长春网站制作推广
  • 微网站开发方案模板百度投广告怎么收费
  • 南通市住房和建设局网站口碑营销推广
  • 网站优化关键词怎么做小说网站排名人气
  • 传媒公司宣传片郑州seo技术服务顾问
  • 凡科建站的应用场景百度快照投诉中心
  • 怎么申请域名和备案企业seo顾问公司