
Entschuldigen Sie, wenn es sich um ein Duplikat handelt (ich bin sicher, es ist ein Duplikat), aber ich kann wirklich nicht finden, wie man es manuell macht. Ich habe die nächste Blockkette erstellt.
Hier sehen Sie eine gekrümmte Linie zwischen dem letzten und dritten Block. Aber ich möchte so etwas:
Und die Frage: Wie kann ich sie auf diese Weise verbinden? Ich bin sicher, dass es ziemlich einfach ist. MWE:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning,automata}
\begin{document}
\begin{tikzpicture}
\node[draw, thick, rectangle] (0) {Data arrival};
\node[draw, thick, rectangle, below of=0] (1) {Coks backoff procedure};
\node[draw, thick, rectangle, below of= 1] (2) {Get trigger-frame?};
\node[draw, thick, rectangle, below of= 2] (3) {Performs backoff procedure};
\node[draw, thick, shape aspect=2.7, diamond, below =0.5cm of 3] (4) {$b<0$?};
\path[>=latex, auto = right,every loop]
(0) edge[] node {} (1)
(1) edge node {} (2)
(2) edge node {} (3)
(3) edge node {} (4)
(4.east) edge[in=0, out=0, looseness=3] node[right] {N} (2.east)
;
\end{tikzpicture}
\end{document}
Antwort1
Der folgende Code verwendet die folgenden Pfadkonstruktionen. Es gibt noch viele weitere, siehe das Tikz-Handbuch oder eine derdie vielen Beispiele im Internet).
(a) -- (b)
beschreibt einen geraden Weg vona
nachb
.(a) -| (b)
beschreibt einen Weg vona
nachb
, zuerst horizontal bis darunter oder darüberb
und dann vertikal.(a) |- (b)
ist gleich, beginnt aber vertikal und setzt sich dann horizontal fort.++(1,-2)
bezeichnet eine Position relativ zur vorhergehenden, 1 Einheit nach rechts und 2 Einheiten nach unten. Dasselbe(a) -| ++(1,-2)
gilt für einen Pfada
, der bei beginnt und 1 Einheit nach rechts und 2 Einheiten nach unten verläuft. Als Nebeneffekt wurde die neue Startposition an das Ende des Pfads verschoben. Also\draw (a) -| ++(1,-2) -| ++(-1,2);
zeichnet ein Rechteck, dessen Endposition wieder bei ist
a
.+(1,-2)
ist grundsätzlich dasselbe wie++(1,-2)
, außer dass sich die Position nicht ändert.\draw (a) -| +(1,-2) -| +(-1,2);
zeichnet zwei Linien mit jeweils einem Winkel, eine rechts von
a
und eine links vona
.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning,automata}
\begin{document}
\begin{tikzpicture}
[>=latex,
action/.style={draw,thick},
test/.style={draw, thick, shape aspect=2.7, diamond}
]
\node[action] (0) {Data arrival};
\node[action, below=of 0] (1) {Coks backoff procedure};
\node[action, below=of 1] (2) {Get trigger-frame?};
\node[action, below=of 2] (3) {Performs backoff procedure};
\node[test, below= 0.5cm of 3] (4) {$b<0$?};
\node[action, left=of 3] (5) {Do something};
\path[->]
(0) edge node {} (1)
(1) edge node {} (2)
(2) edge node {} (3)
(3) edge node {} (4);
\draw[->] (4) -- node[below right,pos=0.2]{N} ++(3,0) |- (2);
\draw[->] (4) -| node[below left,pos=0.1]{Y} (5);
\draw[->] (5) |- (2);
\draw[->] (4) --node[right] {maybe} +(0,-1.5);
\end{tikzpicture}
\end{document}
Antwort2
Leicht modifiziertgernotAntwort (für Freude und Bewegung):
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows, chains, positioning, shapes}% added chains
\makeatletter
\tikzset{supress chain/.code={\def\tikz@after@path{}}}% added for suppress joining of nodes
\makeatother
\begin{document}
\begin{tikzpicture}[
> = latex,
node distance = 5mm and 7mm,% added (not used default value)
start chain = going below,% activation of chains
action/.style = {draw, thick, on chain, join= by ->},% nodes are in chain and connected by ->
test/.style = {diamond, draw, thick, shape aspect=2.4, on chain, join= by ->}% node is in the chain and connected by -> with previous node
]
\node[action] (n0) {Data arrival};
\node[action] (n1) {Coks backoff procedure};
\node[action] (n2) {Get trigger-frame?};
\node[action] (n3) {Performs backoff procedure};
\node[test] (n4) {$b<0$?};
\node[action,
supress chain, % this node is not connected with join
left=of n3] (n5) {Do something};
\draw[->] (n4) -| node[below,pos=0.25] {Y} (n5); % left feedback loop
\draw[->] (n5) |- (n0); % left feedback loop
\draw[->] (n4) -| ([xshift=5mm] n3.east) node[below,pos=0.25] {N} |- (n2); % right feedback loop
\draw[->] (n4.south) -- node[right] {maybe} ++ (0,-1.1);
\end{tikzpicture}
\end{document}
Das Ergebnis ist fast das gleiche: