graph-SCC
strongly connected component(SCC): 里面的任一对顶点都是互相可达的。
一个有向图,将每个SCC缩成一个点,那么这个图就变成了DAG(有向无环图)。
原图进行DFS之后,使post (u)最大的u点必然在source中.
如果C和C'是两个不同的SCC,一条边从C到C',那么C中post值最大的值一定比C'中最大的要大。
寻找SCC的算法:
1 call DFS (G) to compute finishing times post[u] for each vertex u
2 compute GT // GT 即对G中的边取反后得到的图。取反后,SCC内部仍然是通的,但SCC之间就不再是连通的了。
3 call DFS (GT), but in the main loop of DFS, consider the vertices in order of decreasing post[u]
4 output the vertices of each tree in the depth-first forest formed in step 3 as a SCC
计算GT的时间:O(V+E)
两次DFS的时间:O(V+E)
总时间: O(V+E)
算法实现:
graph-SCC的更多相关文章
- poj--2553--The Bottom of a Graph (scc+缩点)
The Bottom of a Graph Time Limit : 6000/3000ms (Java/Other) Memory Limit : 131072/65536K (Java/Oth ...
- [洛谷P3627][APIO2009]抢掠计划
题目大意:给你一张$n(n\leqslant5\times10^5)$个点$m(m\leqslant5\times10^5)$条边的有向图,有点权,给你起点和一些可能的终点.问从起点开始,到任意一个终 ...
- [CF475E]Strongly Connected City 2
题目大意:给一张$n(n\leqslant2000)$个点的无向图,给所有边定向,使定向之后存在最多的有序点对$(a,b)$满足从$a$能到$b$ 题解:先把边双缩点,因为这里面的点一定两两可达. 根 ...
- POJ 2553 The Bottom of a Graph 【scc tarjan】
图论之强连通复习开始- - 题目大意:给你一个有向图,要你求出这样的点集:从这个点出发能到达的点,一定能回到这个点 思路:强连通分量里的显然都可以互相到达 那就一起考虑,缩点后如果一个点有出边,一定不 ...
- poj 2553 The Bottom of a Graph【强连通分量求汇点个数】
The Bottom of a Graph Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 9641 Accepted: ...
- HDU 5313 Bipartite Graph(二分图染色+01背包水过)
Problem Description Soda has a bipartite graph with n vertices and m undirected edges. Now he wants ...
- HDOJ 5409 CRB and Graph 无向图缩块
无向图缩块后,以n所在的块为根节点,dp找每块中的最大值. 对于每一个桥的答案为两块中的较小的最大值和较小的最大值加1 CRB and Graph Time Limit: 8000/4000 MS ( ...
- UVA11324 The Lagest Lique(SCC缩点+DP)
Given a directed graph G, con- sider the following transformation. First, create a new graph T(G) to ...
- 强连通分量SCC 2-SAT
强连通分量SCC 2-SAT 部分资料来自: 1.https://blog.csdn.net/whereisherofrom/article/details/79417926 2.https://ba ...
- 论文解读GALA《Symmetric Graph Convolutional Autoencoder for Unsupervised Graph Representation Learning》
论文信息 Title:<Symmetric Graph Convolutional Autoencoder for Unsupervised Graph Representation Learn ...
随机推荐
- scrapy 一些设置和问题
scrapy设置ua池 设置后在setting启用 DOWNLOADER_MIDDLEWARES = { 'laogou.middlewares.LaogouDownloaderMiddleware' ...
- 《从0到1学习Flink》—— Flink 配置文件详解
前面文章我们已经知道 Flink 是什么东西了,安装好 Flink 后,我们再来看下安装路径下的配置文件吧. 安装目录下主要有 flink-conf.yaml 配置.日志的配置文件.zk 配置.Fli ...
- Vue双向绑定简单实现
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- JAVA 员工管理系统(用抽象类实现),简易版。
package Demo513; /* 定义一个Employee类,该类包含: private 成员变量name,number,birthday,其中birthday为MyDate类的对象: abst ...
- 缓存List并写入文件持久化
LIfe is half spent before we know what is it. 缓存List并写入文件持久化 需要缓存一个List集合,比如缓存一个输入框中用户之前输入过的内容,下次当用户 ...
- 【踩坑】springMVC 接收String参数没有判断为空
今天在调试iReview项目的接口时,发现新增词条和新增库的时候,某些字段即使留空POST到后台时也能当做不为空. 经过排查,发现后台是使用 String 变量名 == null 这样的语句去判断变量 ...
- 【转】HTTPS系列干货(一):HTTPS 原理详解
HTTPS系列干货(一):HTTPS 原理详解 前言 HTTPS(全称:HyperText Transfer Protocol over Secure Socket Layer),其实 HTTPS 并 ...
- jsp-简单的猜数小游戏
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"% ...
- tomcat服务器,从前端到后台到跳转
前端页面: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <tit ...
- Json字符串与js数组互相转换
1.Json数据格式的字符串转换成js数组: JSON.parse(str); // str 字符串格式 2.js数组转换成Json数据格式字符串: var myJSONText = JSON.s ...