📚 The CoCalc Library - books, templates and other resources
License: OTHER
\subsection{SCCs finden}1\begin{frame}{Wie findet man SCCs?}{}2\begin{wrapfigure}{r}{150px}3\begin{center}4\includegraphics{Material/Bob_Tarjan.jpg}5\end{center}6\caption{Robert Tarjan}7\end{wrapfigure}8Algorithmus von Robert Tarjan910% Source: http://commons.wikimedia.org/wiki/File:Bob_Tarjan.jpg1112nutzt Tiefensuche im Graphen13\end{frame}141516\tikzstyle StackBox=[style=help lines,color=blue!50,fill=white]17\tikzstyle{abstract}=[rectangle, draw=black,18fill=orange!40,19text centered, anchor=center, text=white, text width=0.4cm, text height=0.4cm]20\tikzstyle{textstyle}=[rectangle, draw=white,21fill=white, anchor=base west, text=black, text width=3cm, text height=0.4cm]22\tikzstyle{textstyleMini}=[rectangle, draw=white,23fill=white, anchor=center, text=black, text width=0.5cm, text height=0.4cm]2425\begin{frame}2627\begin{algorithm}[H]28\begin{algorithmic}29\Function{startTarjan}{Graph g}30\State $indexCounter \gets 0$31\State $stack$32\ForAll{$node$ in $g$}33\If{$!node.visited$}34\Call{tarjan}{$node$}35\EndIf36\EndFor37\EndFunction38\end{algorithmic}39\caption{Tarjans Algorithmus zur bestimmung starker Zusammenhangskomponenten}40\label{alg:seq1}41\end{algorithm}42\end{frame}4344\begin{frame}45\begin{algorithm}[H]46\begin{algorithmic}47\Function{tarjan}{Node* node}48\State $node.visited \gets $ \textbf{true}49\State $node.index \gets indexCounter++$50\State $stack.push(node)$51\ForAll{$successor$ in $node.successors$}52\If{$!node.visited$}53\Call{tarjan}{successor}54\EndIf55\State $node.lowlink \gets$ \Call{min}{$node.lowlink, successor.lowlink$}56\EndFor5758\boxto<1->{a}\If{$node.lowlink == node.index$}59\Repeat60\State $successor \gets stack.pop()$61\Until{$successor == node$}62\EndIf\tikzmark{a}63\EndFunction64\end{algorithmic}65\label{alg:seq2}66\end{algorithm}6768% To insert the annotation69\begin{tikzpicture}[remember picture,overlay]70\coordinate (a) at ($(a)+(8.5,3)$); % <= adjust this parameter to move the position of the annotation71\node[rectangle,draw, gray,text width=3cm,align=left,right] at (a) {SCC wurde gefunden, ggf. ausgeben};72\end{tikzpicture}73\end{frame}7475\begin{frame}{Wie findet man SCCs?}{}76\begin{figure}77\begin{tikzpicture}[->,scale=1.8, auto,swap]78\node[textstyle] (Text) at (0,3) {Rekursionstiefe:};79\node[textstyle] (RecDepth) at (3,3) {};8081% Draw the vertices82\foreach \pos/\name in {{(0,0)/a}, {(0,2)/b}, {(1,2)/c},83{(1,0)/d}, {(2,1)/e}, {(3,1)/f},84{(4,2)/g}, {(5,2)/h}, {(4,0)/i},85{(5,0)/j}}86\node[vertex] (\name) at \pos {$\name$};8788% Connect vertices with edges89\foreach \source/ \dest /\pos in {a/b/,b/c/,c/d/,d/a/,90c/e/bend left, d/e/,e/c/,91e/f/,92f/g/, f/i/,g/f/bend right,i/f/bend left,93g/h/, h/j/, j/i/, i/g/}94\path (\source) edge [\pos] node {} (\dest);9596% Start animating the vertex and edge selection.97\foreach \vertex / \fr / \lowlink / \index in {a/1/0/0,b/2/1/1,c/3/2/2,d/4/0/3,e/5/2/4,f/6/5/5,g/7/6/6,h/8/7/7,j/9/8/8,i/10/5/9} {98\path<\fr-> node[selected vertex] at (\vertex) {$\vertex_{\lowlink, \index}$};99\path<\fr-> node[textstyleMini] at (RecDepth) {$\index$};100}101% Start animating the edge selection.102% For convenience we use a background layer to highlight edges103% This way we don't have to worry about the highlighting covering104% weight labels.105\begin{pgfonlayer}{background}106\path<4->[ignored edge] (d.center) edge [] node {} (a.center);107\path<5->[ignored edge] (e.center) edge [] node {} (c.center);108\path<10->[ignored edge] (i.center) edge [bend left] node {} (f.center);109\foreach \source / \dest / \fr / \pos in {a/b/2/,b/c/3/,c/d/4/, d/e/5/,e/f/6/,f/g/7/,g/h/8/,110h/j/9/,j/i/10/}111\path<\fr->[selected edge] (\source.center) edge [\pos] node {} (\dest.center);112\end{pgfonlayer}113% go back in recursion114% Start animating.115\foreach \vertex / \fr / \lowlink / \index in {j/11/5/8,h/12/5/7,g/13/5/6,f/14/5/5} {116\path<\fr-> node[selected vertex] at (\vertex) {$\vertex_{\lowlink, \index}$};117\path<\fr-> node[textstyleMini] at (RecDepth) {$\index$};118}119% mark first scc120\begin{pgfonlayer}{background}121\path<15->[color=blue,fill=green!20] (4.2,1) circle (1.6cm);122\end{pgfonlayer}123% go back in recursion124% Start animating.125\foreach \vertex / \fr / \lowlink / \index in {e/16/2/4,c/17/0/3,b/18/0/1,a/19/0/0} {126\path<\fr-> node[selected vertex] at (\vertex) {$\vertex_{\lowlink, \index}$};127\path<\fr-> node[textstyleMini] at (RecDepth) {$\index$};128}129% mark first scc130\begin{pgfonlayer}{background}131\path<20->[color=blue,fill=green!20] (0.6,1) circle (1.6cm);132\end{pgfonlayer}133\end{tikzpicture}134\end{figure}135\end{frame}136137138