Graph mit tikz Thema ist als GELÖST markiert

Tabellen und Grafiken erstellen und anordnen


MayaB.

Graph mit tikz

Beitrag von MayaB. »

Hallo!

ich versuche einen Graphen zu erstellen, der wie folgt aussieht:
Bild

Folgendes mache ich im Moment:
\documentclass[11pt]{article} 

\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,fit,automata,shapes}
\RequirePackage{atbegshi}

\begin{document} 
\begin{tikzpicture}{->,>=stealth',shorten >=1pt,auto,semithick}
	\tikzstyle{every state}=[minimum size=16pt,fill=white,text=black, node distance=2cm]
	\tikzstyle{every pin edge}=[<-,shorten <=1pt]
     
	\node[state,shape=circle]             (a)                {$a$};
	\node[state,shape=circle]             (b) [below of = a] {$b$};
	\node[state,shape=circle]             (c) [above right of = a] {$c$};
	\node[state,shape=circle]             (d) [above right of = b] {$d$};
    \node[state,shape=circle]             (e) [below right of = b] {$e$};
    

              ;
\end{tikzpicture}
\end{document}
Das sieht aber von den Abständen blöd aus! Ich hätte das halt gerne ungefähr so, wie in dem Bild, oder schöner :-)
Ideen?

MayaB.

Beitrag von MayaB. »

Hi,

ich habe das jetzt soweit geschafft, mit absoluten Positionen. Ist vielleicht nicht so elegant, aber funktioniert immerhin :roll:

Dafür habe ich aber neue Probleme:
Ich möchte nämlich zwei Graphen erstellen und diese nebeneinander anordnen. Ich habe das jetzt so probiert:

\documentclass[11pt]{article} 

\usepackage{tikz} 
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,fit,automata,shapes} 
\RequirePackage{atbegshi} 

\newcommand*{\dbdownarrow}{%   % double bar downarrow 
  \vbox{% 
    \hrule height0.5pt 
    \kern1.5pt 
    \hrule height0.5pt 
    \kern-0.45ex 
    \hbox{ 
      \kern-0.25em 
      \ensuremath{\downarrow} 
      \kern-0.25em 
    } 
  } 
} 
\begin{document} 

\begin{figure}[!H] 
\caption{test} 
\begin{minipage}{2cm} 
\begin{flushleft} 
\begin{tikzpicture}{->,>=stealth',shorten >=1pt,auto,semithick} 
   \tikzstyle{every state}=[minimum size=16pt,fill=white,text=black, node distance=2cm] 
   \tikzstyle{every pin edge}=[<-,shorten <=1pt] 
      
   \node[state,shape=circle]             (a)                {$a$}; 
   \node[state,shape=circle]             (b) at (0, -1.5) {$b$}; 
   \node[state,shape=circle]             (c) at (1.5,0.75) {$c$}; 
   \node[state,shape=circle]             (d) at (1.5,-0.75) {$d$}; 
    \node[state,shape=circle]             (e) at (1.5,-2.25) {$e$}; 
    
    \path[->]    (a) edge node[above] {$\dbdownarrow$} (c) 
                 (a) edge node[above, very near end] {$\dbdownarrow$} (e) 
                 (b) edge node[above, near end] {$\downarrow$}   (d)   
    
              ; 
\end{tikzpicture} 
\end{flushleft} 
\end{minipage} 
\begin{minipage}{2cm} 
\begin{flushright} 
\begin{tikzpicture}{->,>=stealth',shorten >=1pt,auto,semithick} 
   \tikzstyle{every state}=[minimum size=16pt,fill=white,text=black, node distance=1.5cm] 
   \tikzstyle{every pin edge}=[<-,shorten <=1pt] 
      
   \node[state,shape=circle]             (c)                {$c$}; 
   \node[state,shape=circle]             (d) [below of = c] {$d$}; 
   \node[state,shape=circle]             (e) [below of = d] {$e$}; 
   \node[state,shape=circle]             (c1)[right of = c] {$c$}; 
    \node[state,shape=circle]             (d1)[right of = d] {$d$}; 
    \node[state,shape=circle]             (e1) [right of = e] {$e$}; 
    
    \path[->]    (c) edge node[above] {$\dbdownarrow$} (c1) 
                 (d) edge node[above] {$\downarrow$} (d1) 
              ; 
\end{tikzpicture} 
\end{flushright} 
\end{minipage} 
\end{figure} 


\end{document} 
das sieht aber insofern bescheiden aus, dass die Graphen aus irgendeinem Grund
1. nicht auf gleicher Höhe sind
2. direkt aneinander liegen.


Als weiteres würde ich gerne die einzelnen Graphen noch beschriften. Wie mache ich das am schönsten? :-)

Gruß,
maya

feuersaenger
Forum-Fortgeschrittener
Forum-Fortgeschrittener
Beiträge: 91
Registriert: Mi 5. Okt 2011, 18:24
Wohnort: Rheinbach

Beitrag von feuersaenger »

Hallo MayaB,

dies ist vielleicht keine vollstaendige Antwort, aber zumindest koennte die 'baseline' option von TikZ fuer Dich interessant sein: sie erlaubt die Kontrolle des vertikalen alignments (d.h die hoehenverschiebung).

Vielleicht waere sowas wie
\begin{minipage}{\linewidth}
\begin{tikzpicture}[baseline]
...
\end{tikzpicture}%
\hfill
\begin{tikzpicture}[baseline]
...
\end{tikzpicture}%
\end{minipage}
die richtige Loesung: das \hfill macht die links/rechts-Ausrichtung (zusammen mit der minipage, die die gesamte breite einnimmt) und das baseline macht die hoehenverschiebung.

Wenn man nur 'baseline' angibt, macht der das alignment auf der "y=0pt" linie. Wenn man 'baseline=1cm' angibt, dann nimmt er "y=1cm" zur Hoehenausrichtung.

Mit liebem Gruss

Christian

Antworten