Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to draw a cut through the graph, like a line passing through the edges from the source to gamma, source to alpha and source to omega. I am doing that to demonstrate a minimum cut in a network ((Algorithm analysis ))

\begin{tikzpicture}
[scale=.8,auto=left,every node/.style={circle,fill=blue!20}]
\tikzset{vertex/.style = {shape=circle,draw,minimum size=1.5em}}
\tikzset{edge/.style = {->,> = latex'}}

  \node (s) at (0,5){source};
  \node (v1) at (5,9){alpha};
  \node (v4) at (13,9){beta};
  \node (v2) at (5,1){omega};
  \node (v3) at (6,5){gamma};
  \node (v5) at (13,1){theta};
  \node (v6) at (16,5){delta};
  \node (t) at (20,5){sink};

\tikzset{EdgeStyle/.style={->}}
\Edge[label=$1/1$](s)(v1);
\Edge[label=$4/4$](s)(v2);
\Edge[label=$2/2$](s)(v3);
\Edge[label=$2/2$](v2)(v4);
\Edge[label=$2/2$](v2)(v5);
\Edge[label=$1/1$](v1)(v4);
\Edge[label=$1/1$](v3)(v4);
\Edge[label=$4/4$](v6)(t);
\Edge[label=$1/1$](v5)(t);
\Edge[label=$2/2$](v4)(t);
\Edge[label=$1/4$](v5)(v6);
\Edge[label=$1/1$](v3)(v6);
\Edge[label=$2/2$](v4)(v6);


\end{tikzpicture}
share|improve this question
3  
It would be helpful if you were to provide a complete minimum working example (MWE), beginning with \documentclass and showing all the packages and options you are using. Think of the time it will save those trying to help you. Help us help you. –  Steven B. Segletes Apr 7 at 1:09
1  
I'm sure others will know but I, at least, have no idea how to get that to compile. Which package defines \Edge? –  cfr Apr 7 at 1:21

2 Answers 2

Using the calc library you can say something like

\draw[dashed] 
  ([yshift=60pt]$ (s)!0.5!(v1) $ ) -- 
  ([yshift=-60pt]$ (s)!0.5!(v2) $ );

A complete example:

\documentclass{article}
\usepackage{tkz-graph}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}
[scale=.8,auto=left,every node/.style={circle,fill=blue!20}]
\tikzset{vertex/.style = {shape=circle,draw,minimum size=1.5em}}
\tikzset{edge/.style = {->,> = latex'}}

  \node (s) at (0,5){source};
  \node (v1) at (5,9){alpha};
  \node (v4) at (13,9){beta};
  \node (v2) at (5,1){omega};
  \node (v3) at (6,5){gamma};
  \node (v5) at (13,1){theta};
  \node (v6) at (16,5){delta};
  \node (t) at (20,5){sink};

\tikzset{EdgeStyle/.style={->}}
\Edge[label=$1/1$](s)(v1);
\Edge[label=$4/4$](s)(v2);
\Edge[label=$2/2$](s)(v3);
\Edge[label=$2/2$](v2)(v4);
\Edge[label=$2/2$](v2)(v5);
\Edge[label=$1/1$](v1)(v4);
\Edge[label=$1/1$](v3)(v4);
\Edge[label=$4/4$](v6)(t);
\Edge[label=$1/1$](v5)(t);
\Edge[label=$2/2$](v4)(t);
\Edge[label=$1/4$](v5)(v6);
\Edge[label=$1/1$](v3)(v6);
\Edge[label=$2/2$](v4)(v6);

\draw[dashed] 
  ([yshift=60pt]$ (s)!0.5!(v1) $ ) -- 
  ([yshift=-60pt]$ (s)!0.5!(v2) $ );

\end{tikzpicture}

\end{document} 

enter image description here

share|improve this answer
    
doesn't work give me errors –  bebo Apr 7 at 1:44
    
sorry it works now , thank you sooo much –  bebo Apr 7 at 1:45
    
@bebo You're welcome! Don't forget that you can accept answers that you consider solved your problem by clicking the checkmark to their left. In case of doubt, please see How do you accept an answer?. –  Gonzalo Medina Apr 7 at 1:47

One can add the cuts externally to the picture after the fact with \stackinset

\documentclass{article}
\usepackage[margin=2cm]{geometry}
\usepackage{tkz-graph}
\usetikzlibrary{calc}
\usepackage{graphicx}
\usepackage{stackengine}
% DASHED LINE OF SPECIFIED LENGTH
% From morsburg at http://tex.stackexchange.com/questions/12537/
% how-can-i-make-a-horizontal-dashed-line/12553#12553
\def\dashfill{\cleaders\hbox to .6em{-}\hfill}
\newcommand\dashline[1]{\hbox to #1{\dashfill\hfil}}
\begin{document}
\savestack{\mygraph}{\begin{tikzpicture}
[scale=.8,auto=left,every node/.style={circle,fill=blue!20}]
\tikzset{vertex/.style = {shape=circle,draw,minimum size=1.5em}}
\tikzset{edge/.style = {->,> = latex'}}
  \node (s) at (0,5){source};
  \node (v1) at (5,9){alpha};
  \node (v4) at (13,9){beta};
  \node (v2) at (5,1){omega};
  \node (v3) at (6,5){gamma};
  \node (v5) at (13,1){theta};
  \node (v6) at (16,5){delta};
  \node (t) at (20,5){sink};
\tikzset{EdgeStyle/.style={->}}
\Edge[label=$1/1$](s)(v1);
\Edge[label=$4/4$](s)(v2);
\Edge[label=$2/2$](s)(v3);
\Edge[label=$2/2$](v2)(v4);
\Edge[label=$2/2$](v2)(v5);
\Edge[label=$1/1$](v1)(v4);
\Edge[label=$1/1$](v3)(v4);
\Edge[label=$4/4$](v6)(t);
\Edge[label=$1/1$](v5)(t);
\Edge[label=$2/2$](v4)(t);
\Edge[label=$1/4$](v5)(v6);
\Edge[label=$1/1$](v3)(v6);
\Edge[label=$2/2$](v4)(v6);
\end{tikzpicture}}
\stackinset{c}{7cm}{c}{}{\rotatebox{90}{\dashline{2in}}}{%
\stackinset{c}{-4.6cm}{c}{-1.5cm}{\rotatebox{-38}{\dashline{3.2in}}}{%
\stackinset{c}{}{c}{1cm}{\dashline{6in}}{%
\mygraph}}}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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