2

Is there a package or a package extension for drawing cause effect graphs (see the screenshot below for atomic elements).

If there is no package can someone explain how I can achieve this by using tikz, especially the negation sign and the curved lines.

enter image description here

3
  • automata library? pics? graphs library and declare some new standard structures?
    – cfr
    Nov 8, 2015 at 22:03
  • 1
    And how is it possible for example for the automata library to define the negation symbol?
    – d4rty
    Nov 8, 2015 at 22:19
  • I more meant that you might find it helpful as a starting point. Obviously it is not going to provide an out-of-the-box solution. It might not be worth it, though. You might be better off just using pics or graphs. It depends partly on the details of how you are going to need to combine these 'atomic' elements.
    – cfr
    Nov 8, 2015 at 22:54

1 Answer 1

9

You can do this:

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,decorations.markings,automata,angles,quotes}

\tikzset{
  myneg/.style={
    decoration={
      markings,
      mark=at position 0.5 with 
        {\draw (0,0) arc (0:180:#1) (0,0) arc (180:360:#1);}
    },
    postaction=decorate
  },
  myneg/.default=6pt,
  mynode/.style={
    draw,
    circle,
    minimum size=20pt
  }
}

\begin{document}

\begin{tikzpicture}
\node[mynode] (a) at (0,0) {$a$};
\node[mynode] (b) at (3,0) {$b$};
\draw 
  (a) -- (b) node[above=8pt,midway,font=\scshape] {identity};
\begin{scope}[xshift=5cm]
\node[mynode] (a) at (0,0) {$a$};
\node[mynode] (b) at (3,0) {$b$};
\draw[myneg] 
  (a) -- (b) node[above=8pt,midway,font=\scshape] {not};
\end{scope}
\begin{scope}[yshift=-4cm]
\node[mynode] (a) at (0,2) {$a$};
\node[mynode] (b) at (0,0) {$b$};
\node[mynode] (c) at (0,-2) {$c$};
\node[mynode] (d) at (3,0) {$d$};
\coordinate (aux) at (d.west);  
\foreach \Value in {a,b,c}
  \draw (\Value) -- (aux);
\path 
  pic[draw,angle radius=35pt,"\raisebox{20pt}{$\lor$}",
    angle eccentricity=1.25] 
  {angle=a--aux--c};  
\path (a) -- (d) node[above=12pt,midway,font=\scshape] {or};  
\end{scope}
\begin{scope}[xshift=5cm,yshift=-4cm]
\node[mynode] (a) at (0,2) {$a$};
\node[mynode] (b) at (0,-2) {$b$};
\node[mynode] (c) at (3,0) {$c$};
\foreach \Value in {a,b}
  \draw (\Value) -- (c.west);
\path 
  (a) -- (c) 
  node[above=12pt,midway,font=\scshape] {and};
\node[left=of c,font=\scshape] {$\land$};  
\end{scope}
\end{tikzpicture}

\end{document}

enter image description here

The negation was obtained using a decoration (with the help of the decorations.markings library) and the arc for the "OR" was produced with the help of the angles library.

Of course, depending on the actual kind of application, you could use additional libraries for the nodes, such as automata or chains.

An additional example showing the negation and or paths in action:

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,decorations.markings,automata,angles,quotes}

\tikzset{
  myneg/.style={
    decoration={
      markings,
      mark=at position 0.5 with 
        {\draw (0,0) arc (0:180:#1) (0,0) arc (180:360:#1);}
    },
    postaction=decorate
  },
  myneg/.default=6pt,
  mynode/.style={
    draw,
    circle,
    minimum size=20pt
  }
}

\begin{document}

\begin{tikzpicture}[node distance=1cm and 2cm]
\node[mynode] (b) at (0,0) {$b$};
\node[mynode,above=of b] (a) {$a$};
\node[mynode,below=of b] (c) {$c$};
\node[mynode,right=of b] (d) {$d$};
\node[mynode,above right=of d] (e) {$e$};
\node[mynode,below right=of d] (f) {$f$};
\coordinate (aux) at (d.west);  
\foreach \Value in {a,b,c}
  \draw (\Value) -- (aux);
\path 
  pic[draw,angle radius=35pt,"\raisebox{20pt}{$\lor$}",
    angle eccentricity=1.25] 
  {angle=a--aux--c};  
\draw[myneg]
  (d) -- (e);
\draw[myneg]
  (d) -- (f);
\end{tikzpicture}

\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .