【图论】【强连通分量】【Tarjan】pascal+邻接表
来源:互联网 发布:电话视频软件 编辑:程序博客网 时间:2024/05/21 07:01
const maxn = 100000; maxm = 2*maxn;var cost,toit,next:array[0..maxm] of longint; list,dfn,low,stack:array[0..maxn] of longint; n,m,top,i,j,d,tot,a,b,c:longint; f,vis:array[0..maxn] of boolean;procedure add(a,b,c:longint);begin inc(tot); cost[tot]:=c; toit[tot]:=b; next[tot]:=list[a]; list[a]:=tot;end;function min(a,b:longint):longint;begin if a<b then exit(a) else exit(b);end;procedure print(x:integer);begin while stack[tot]<>x do begin writeln(stack[tot],' '); f[stack[tot]]:=false; dec(tot); end; writeln(stack[tot]); f[stack[tot]]:=false; dec(tot);end;procedure dfs(x:integer);var i,k,v:longint;begin inc(d); dfn[x]:=d; low[x]:=d; inc(tot); stack[tot]:=x; f[x]:=true; k:=list[x]; while k<>0 do begin v:=toit[k]; if not vis[v] then begin vis[v]:=true; dfs(v); low[x]:=min(low[x],low[v]); end else if f[v] then low[x]:=min(low[x],dfn[v]); k:=next[k]; end; if dfn[x]=low[x] then print(x);end;begin fillchar(list,sizeof(list),0); fillchar(next,sizeof(next),0); fillchar(toit,sizeof(toit),0); fillchar(f,sizeof(f),false); fillchar(vis,sizeof(vis),false); readln(n,m); tot:=0; for i:=1 to m do begin readln(a,b); add(a,b); end; d:=0;tot:=0; for i:=1 to n do if not vis[i] then begin vis[i]:=true; dfs(i); end; end.
0 0
- 【图论】【强连通分量】【Tarjan】pascal+邻接表
- 强连通分量tarjan
- 强连通分量 Tarjan
- Tarjan强连通分量
- 强连通分量-Tarjan
- hdu1269--求强连通分量个数--tarjan--图的静态邻接表
- 强连通分量 ( Tarjan,邻接链表 )——The Bottom of a Graph ( POJ 2553 )
- tarjan求强连通分量
- 强连通分量 Tarjan算法
- POJ1236强连通分量tarjan
- 强连通分量 tarjan算法
- poj1236强连通分量(Tarjan)
- tarjan 求强连通分量
- 强连通分量Tarjan模板
- 强连通分量Tarjan算法
- Tarjan强连通分量算法
- 强连通分量(Tarjan)
- hdu1269 强连通分量tarjan
- 数据结构实验之图论二:基于邻接表的广度优先搜索遍历
- 调用Android系统设置项
- 进程切换源码分析
- CODE[VS] 3955 最长严格上升子序列(加强版)
- java_Swing之弹窗设计初次接触。
- 【图论】【强连通分量】【Tarjan】pascal+邻接表
- 博客搬迁
- 20161114
- 1.微信小程序-B站:前言准备
- Android 完美获取Ip地址
- spring boot (三) 集成 mybatis
- Skyline中shp读写:shp到Datable、DataTable到shp
- 模拟实现strlen函数(二)
- Windows CPU占用率过高