![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
图论
HeisenbergWDG
努力学习中
展开
-
1584. Min Cost to Connect All Points最小生成树时间复杂度对比
You are given an arraypointsrepresenting integer coordinates of some points on a 2D-plane, wherepoints[i] = [xi, yi].The cost of connecting two points[xi, yi]and[xj, yj]is themanhattan distancebetween them:|xi- xj| + |yi- yj|, where|val|den...原创 2021-03-13 13:33:15 · 155 阅读 · 0 评论 -
图平台技术及应用实践
https://blog.csdn.net/oppotech/article/details/103387841转载 2021-02-26 17:38:37 · 116 阅读 · 0 评论 -
743. Network Delay Time最短路dijkstra,Bellman-Ford,Floyd-Warshall算法不同版本合集
There areNnetwork nodes, labelled1toN.Giventimes, a list of travel times asdirectededgestimes[i] = (u, v, w), whereuis the source node,vis the target node, andwis the time it takes for a signal to travel from source to target.Now, we sen...原创 2020-10-22 22:07:14 · 209 阅读 · 0 评论 -
HDU1285拓扑排序
Problem Description有N个比赛队(1<=N<=500),编号依次为1,2,3,。。。。,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接获得每个队的比赛成绩,只知道每场比赛的结果,即P1赢P2,用P1,P2表示,排名时P1在P2之前。现在请你编程序确定排名。Input输入有若干组,每组中的第一行为二个数N(1<=N<=500),M;其中N表示队伍的个数,M表示接着有M行的输入数据。接下来的M行数据中,每行.原创 2020-05-20 15:53:24 · 216 阅读 · 1 评论 -
HDU1533最小费用流
Problem DescriptionOn a grid map there are n little men and n houses. In each unit time, every little man can move one unit step, either horizontally, or vertically, to an adjacent point. For each little man, you need to pay a $1 travel fee for every ste原创 2020-05-17 19:07:21 · 314 阅读 · 0 评论 -
HDU1083最大匹配(匈牙利算法)
Problem DescriptionConsider a group of N students and P courses. Each student visits zero, one or more than one courses. Your task is to determine whether it is possible to form a committee of exactly P students that satisfies simultaneously the conditio原创 2020-05-17 10:40:57 · 450 阅读 · 0 评论 -
最大流标号程序实例
原创 2020-05-17 08:56:27 · 323 阅读 · 0 评论 -
完美匹配-匈牙利算法
https://blog.csdn.net/lady_killer9/article/details/103586834转载 2020-05-16 18:15:22 · 394 阅读 · 0 评论 -
HDU3549最大流(Ford-Fulkserson和Dinic版本)
Problem DescriptionNetwork flow is a well-known difficult problem for ACMers. Given a graph, your task is to find out the maximum flow for the weighted directed graph.InputThe first line of input contains an integer T, denoting the number of te..原创 2020-05-15 19:10:42 · 285 阅读 · 0 评论 -
HDU3790:最短路径问题(Dijkstra)
Problem Description给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费最少的。Input输入n,m,点的编号是1~n,然后是m行,每行4个数 a,b,d,p,表示a和b之间有一条边,且其长度为d,花费为p。最后一行是两个数 s,t;起点s,终点。n和m为0时输入结束。(1<n<=1000, 0<m<100000, s != t)Output输出..原创 2020-05-14 10:15:05 · 302 阅读 · 0 评论 -
HDU1874最短路径(dijkstra,Bellman-Ford,Floyd-Warshall算法不同版本合集)
Problem Description某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。Input本题目包含多组数据,请处理到文件结束。每组数据第一行包含两个正整数N和M(0<N<200,0<M<1000),分别代表现有城镇的数目和已修建的道路的数目。.原创 2020-05-12 16:05:02 · 367 阅读 · 0 评论 -
POJ1679 最小生成树是否唯一
DescriptionGiven a connected undirected graph, tell if its minimum spanning tree is unique.Definition 1 (Spanning Tree): Consider a connected, undirected graph G = (V, E). A spanning tree of G is a subgraph of G, say T = (V', E'), with the following pro原创 2020-05-11 18:03:22 · 364 阅读 · 0 评论 -
POJ1251最小生成树
DescriptionThe Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentlessly, so the large road network is too expensive原创 2020-05-11 11:17:51 · 285 阅读 · 0 评论 -
研一图论期末复习
把我复习的笔记放上来,也顺便留个纪念了。原创 2019-12-28 22:32:16 · 673 阅读 · 0 评论 -
哥尼斯堡七桥——Euler欧拉定理证明
昨天和同学复习图论,深入讨论了欧拉定理,有了相对透彻的理解,我希望写下来,我的博客就是我的笔记本,记录学习的点点滴滴而已。定理5.1 设G为非空连通图,则G为 Euler图 <=>G中无度为奇数的顶点。文字版我仔细的解释和理下思路。证明=>:令C = u0 e1 u1 e2 u2 ... ue (ue = u0 )为G的一Euler环游 ,起点为...原创 2019-12-28 17:15:32 · 1858 阅读 · 0 评论 -
网络流——最大流问题例题
https://www.jianshu.com/p/e4548c5c381e转载 2019-12-19 23:45:49 · 3341 阅读 · 0 评论 -
迪杰斯特拉(python)
n,m=map(int, input('node number and edge number:').split())INF=0x3f3f3f#print(INF)e=[]for i in range(n): e.append([]) for j in range(n): e[i].append(INF) if i==j: e[i][j]=0for i in rang...原创 2019-11-01 14:23:08 · 199 阅读 · 0 评论 -
图论1 图的深度搜索和广度搜索
声明:这个是2018年写的播客,现在是2019年8月我又来复习了,现在csdn改革了,转载需要表明原文链解,我找不到了,只能写原创了,罪过。。。怪我当时知识产权意识不强。本文总结了图的深度优先搜索,图的广度优先搜索,邻接链表和邻接矩阵的实现,并查集的实现。0),预备知识 基础词汇:有向图,无向图,带权有向图,带权无向图,有向图中<Vi, Vj>:即Vi---&g...原创 2018-08-21 20:22:13 · 319 阅读 · 0 评论 -
HDU1142(dijstra+记忆化dfs搜索)
Problem DescriptionJimmy experiences a lot of stress at work these days, especially since his accident made working difficult. To relax after a hard day, he likes to walk home. To make things even n...原创 2018-09-11 17:12:25 · 314 阅读 · 0 评论 -
Leetcode 200. Number of Islands深度优先搜索DFS
Given a 2d grid map of'1's (land) and'0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume...原创 2019-03-14 15:03:24 · 192 阅读 · 0 评论 -
Leetcode 207. Course Schedule拓扑排序
复习了vector<pair<int, int>>使用方法There are a total ofncourses you have to take, labeled from0ton-1.Some courses may have prerequisites, for example to take course 0 you have to first ...原创 2019-03-16 14:37:59 · 240 阅读 · 0 评论 -
Leetcode 210. Course Schedule II 拓扑排序
There are a total ofncourses you have to take, labeled from0ton-1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair...原创 2019-03-16 15:21:53 · 164 阅读 · 0 评论 -
Leetcode 695. Max Area of Island深度优先搜索DFS
Given a non-empty 2D arraygridof 0's and 1's, anislandis a group of1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrou...原创 2019-08-07 09:14:45 · 177 阅读 · 0 评论 -
leetcode 463. Island Perimeter计算图形的周长perimeter
You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water.Grid cells are connected horizontally/vertically (not diagonally). The grid is completely...原创 2019-08-07 09:47:07 · 218 阅读 · 0 评论 -
leetcode 630. Course Schedule III最多上多少门课程
There arendifferent online courses numbered from1ton. Each course has some duration(course length)tand closed ondthday. A course should be takencontinuouslyfortdays and must be finished b...原创 2019-08-09 10:30:38 · 372 阅读 · 0 评论 -
leetcode 847. Shortest Path Visiting All Nodes访问所有节点的最短路径
An undirected, connected graph of N nodes (labeled0, 1, 2, ..., N-1) is given asgraph.graph.length = N, andj != iis in the listgraph[i]exactly once, if and only if nodesiandjare connected....原创 2019-08-07 11:13:36 · 289 阅读 · 0 评论 -
leetcode 934. Shortest Bridge最短桥距离
In a given 2D binary arrayA, there are two islands. (An island is a 4-directionally connected group of1s not connected to any other 1s.)Now, we may change0s to1s so as to connect the two island...转载 2019-08-10 17:30:57 · 221 阅读 · 0 评论 -
Leetcode 127. Word Ladder单词变换
Given two words (beginWordandendWord), and a dictionary's word list, find the length of shortest transformation sequence frombeginWordtoendWord, such that:Only one letter can be changed at a ti...原创 2019-08-10 17:58:18 · 213 阅读 · 0 评论 -
图论2:图的四种最短路径算法
抱歉:早期的文章,当时忘记把原帖地址留下,很抱歉,违背了老师教我的一定要把参考文献地址写上的原则,很愧疚。本文总结了图的几种最短路径算法的实现:深度或广度优先搜索算法,弗洛伊德算法,迪杰斯特拉算法,Bellman-Ford算法1),深度或广度优先搜索算法(解决单源最短路径)从起始结点开始访问所有的深度遍历路径或广度优先路径,则到达终点结点的路径有多条,取其中路径权值最短的一条则为最短路径...转载 2018-08-22 10:52:54 · 1952 阅读 · 0 评论