Quantcast
Channel: Question and Answer » tikz-arrows
Viewing all articles
Browse latest Browse all 33

How to add arrow to connect between node Tikz?

$
0
0

I have the block nodes as below figure. I want to connect them by arrow, with bold font. Could you help me to look at my code and update them? Thank you so much

This is my current result

enter image description here

This is my expected result

enter image description here

One more thing, the graph does not show the center of page. Is it possible to adjust its position?

documentclass[preprint,12pt, sort&compress]{elsarticle}
usepackage{tikz}
usetikzlibrary{trees}
usepackage{varwidth}
usetikzlibrary{arrows,shapes,positioning,shadows,trees,calc}
begin{document}

begin{figure}[h]
centering
begin{tikzpicture}[
every node/.style={draw, rectangle},
edge from parent path={
(tikzparentnode) |-   % Start from parent
($(tikzparentnode)!0.5!(tikzchildnode)$) -| % make an ortho line to mid point
(tikzchildnode)},
second/.style   ={level distance=18ex},
third/.style   ={level distance=18ex},
fourth/.style   ={level distance=10ex},
]                            % make another ortho to the target

  node (A){This is first block}
  [sibling distance=9cm]
  child {node (B) {begin{varwidth}{6cm}The second block 1end{varwidth}}
  [sibling distance=6cm]
    child [third]{node {begin{varwidth}{3cm}Third level block left 2end{varwidth}}
    [sibling distance=3cm]
         child [fourth]{node  {begin{varwidth}{3cm}Last block 1end{varwidth}}}         
         child [fourth]{node {begin{varwidth}{3cm}Last block 2end{varwidth}}}
    }
    child [second]{node {begin{varwidth}{3cm}Third level block left 2end{varwidth}}
    [sibling distance=3cm]
         child [fourth]{node  {begin{varwidth}{3cm}Last block 3end{varwidth}}}         
         child [fourth]{node {begin{varwidth}{3cm}Last block 4end{varwidth}}}
    }
  }
  child {node {The second block 2}
  [sibling distance=3.5cm]
    child [third]{node {begin{varwidth}{3cm}Third level block right 1end{varwidth}}}
    child [third]{node {begin{varwidth}{3cm}Third level block right 2end{varwidth}}}
  };


end{tikzpicture}
end{figure}
end{document}

UPDATE: Regarding the ans. of smike. I Obtained the result as below. But it has two problem
1. The figure did not center of the page

  1. The width line of block look more thick. I want all blocks have same thick

enter image description here


Viewing all articles
Browse latest Browse all 33

Latest Images

Trending Articles



Latest Images