图
图相关算法
奇迹是执着的人创造的
这个作者很懒,什么都没留下…
展开
-
算法笔记 10.1 图的定义和相关术语 10.2 图的存储
图:由顶点(Vertex)和边(Edge)组成 无向图:顶点的度是指和该顶点相连的边的条数。 有向图:入度:入边条数 出度:出边条数 边权和点权不一样: 顶点和边都可以有一定属性,量化的属性称为权值,顶点的权值和边的权值分别称为点权和边权。 eg:点权:城市里资源的数目 边权:两个城市之间来往所需要的时间或花费 10.2 图的存储 图的存储两种方式...原创 2019-04-20 21:42:23 · 147 阅读 · 0 评论 -
10.3 图的遍历
10.3.1 DFS遍历图 1.用DFS遍历图 邻接矩阵版: const int MAXV=1000;//最大顶点数 const int INF=1e9;//无穷大 //邻接矩阵DFS int n,G[MAXV][MAXV];//n为顶点数,MAXV为最大顶点数 bool vis[MAXV]={false};//如果顶点i已被访问,则vis[i]=true,初值为false void ...原创 2019-04-26 10:59:29 · 137 阅读 · 0 评论 -
PAT A1034 Head of a Gang
1034Head of a Gang(30分) One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call betweenAandB, we say thatAandBis related. The weight of a...原创 2019-04-26 20:11:41 · 173 阅读 · 0 评论 -
PAT A1076 Forwards on Weibo (30 分)
1076Forwards on Weibo(30分) Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed wi...原创 2019-04-26 23:21:55 · 159 阅读 · 0 评论 -
codeup 10.3小节——图算法专题->图的遍历
问题 A: 第一题 时间限制:1 Sec内存限制:32 MB 提交:545解决:115 [提交][状态][讨论版][命题人:外部导入] 题目描述 该题的目的是要你统计图的连通分支数。 输入 每个输入文件包含若干行,每行两个整数i,j,表示节点i和j之间存在一条边。 输出 输出每个图的联通分支数。 样例输入 1 4 4 3 5 5 样例输出 2 本题难点...原创 2019-04-27 00:12:53 · 142 阅读 · 0 评论 -
PAT A1003 Emergency (25 分)
1003Emergency(25分) As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams...原创 2019-05-02 00:59:27 · 163 阅读 · 0 评论 -
PAT A1030 Travel Plan (30 分)
1030Travel Plan(30分) A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to d...原创 2019-05-02 15:47:48 · 255 阅读 · 0 评论