7

I want to draw '->' for each path.

Actually I tried to add every node option and '->', but this doesn't work.

I know that \draw[->] (t1)--(t2); \draw[->] (t2)--(t3); ... would be work.

But I want to know simple solution.

Is there any simple solution?

enter image description here

\begin{figure} \begin{tikzpicture}[auto, block/.style = {rectangle, draw}]
\matrix[every node/.style = block, column sep=4mm, row sep=6mm]{    
        \node (t1) {host}; & & \node (t11) {host}; \\
        \node (t2) {ICMP}; & & \node (t10) {ICMP}; \\
        \node (t3) {ICMP}; & & \node (t9) {ICMP}; \\ 
        \node (t4) {host}; & & \node (t8) {host}; \\ 
        \node (t5) {ICMP}; & \node (t6) {dd}; & \node (t7) {ICMP}; \\ 
    }; 
    \path[draw, every node, ->] (t1)--(t2)--(t3)->(t4)->(t5)->(t6)->(t7)->(t8)->(t9)->(t10);
    \end{tikzpicture} \end{figure}
6

The path is treated as a single object and therefore the segments themselves can't have arrows. But you can easily draw the path in a loop, and then each segment can have its own arrow:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}[auto, block/.style = {rectangle, draw}]
\matrix[every node/.style = block, column sep=4mm, row sep=6mm]{    
        \node (t1) {host}; & & \node (t11) {host}; \\
        \node (t2) {ICMP}; & & \node (t10) {ICMP}; \\
        \node (t3) {ICMP}; & & \node (t9) {ICMP}; \\ 
        \node (t4) {host}; & & \node (t8) {host}; \\ 
        \node (t5) {ICMP}; & \node (t6) {dd}; & \node (t7) {ICMP}; \\ 
    };
    \foreach \x [remember=\x as \lastx (initially 1)] in {2,...,11}{
    \path[draw, ->] (t\lastx)--(t\x);
    }
    \end{tikzpicture}
\end{document}

output of code

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.