1

I have tried to calculate the intersection, and add a red dot, between a curve called "mincut" and a line called "arc-67".

It doesn't work and gives an error like this: ! Package pgf Error: No shape named `intersection-1' is known.

Trying a simpler code which can be found in the documentation doesn't give any error at all. Can this be some sort of compatibility issue by loading too many Tikz packages?

\documentclass[border=5pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\usepackage{adjustbox} \usepackage{tikz} \usetikzlibrary{intersections} \usetikzlibrary{shapes,arrows,fit,automata} \usetikzlibrary{arrows.meta, calc, positioning, quotes }

\begin{document}

\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto, node distance = 20mm and 40mm, semithick] \tikzstyle{every state}=[circle, black, draw=red, very thick] \tikzset{ basic/.style={ draw=blue, line width=1pt, ->, % alwways draw arrow tip >=stealth, % style of arrow tip shorten >=2pt, % shorten a bit, so that it doesn't quite shorten <=2pt, % touch the nodes preaction={ % provide a wider white background for draw=white, % each arrow for the intersection effect line width=3pt, -, % no arrow tip for background } } } \tikzstyle{mincut}=[dashed, green!40!black, very thick,-,line width=3pt] \tikzstyle{inc_flow}=[basic,line width=3pt] \tikzstyle{nobasic}=[basic,dashed]

\def\circledarrow#1#2#3{ % #1 Style, #2 Center, #3 Radius \draw[#1,<-] (#2) +(80:#3) arc(80:-260:#3); }

\node[state] (1-1) [ label=left:{\large $(4^-,3) $}] {1}; \node[state] (4-1) [right= of 1-1, label=above left:{\large $(2^+,3) $}] {4}; \node[state] (2-1) [above= of 4-1, label=above:{\large $(s^+,3) $}] {2}; \node[state] (3-1) [right=of 2-1, label=above:{\large $ $}] {3}; \node[state] (5-1) [below= of 3-1, label=left :{\large $ (2^+,2) $}] {5}; \node[state] (6-1) [below right=2 and 1.7 of 4-1, label=below:{\large $(4^+,2) $}] {6}; \node[state] (7-1) [right= of 5-1, label=right:{\large $ $}] {7};

\node[state] (s-1) [left=8 of 2-1, label=above:{\large $ (-,\infty) $}] {s}; \node[state] (e-1) [below= of 7-1, label=below:{\large $ $}] {e};

%%% % grafo con costos relativos %%%

% \foreach \inode in {s,1,2,3,4,5,6,7,e}{ % \node[state] (\inode-1) [below=8 of \inode, label=left:{\large $ $}] {\inode}; % }

\path[basic] (s-1) edge node[sloped,above] {\large $5,0,5$} (1-1); \path[basic] (s-1) edge node[sloped,above] {\large $3,0,0$} (2-1); \path[basic,out=30,in=150] (s-1) edge node[sloped,above] {\large $3,0,2$} (3-1); \path[basic,out=270,in=180] (s-1) edge node[sloped,above] {\large $2,0,2$} (6-1);

\path[nobasic] (1-1) edge node[sloped,above] {\large $2,2$} (2-1); \path[basic] (1-1) edge node[sloped,above] {\large $3,0,3$} (4-1); \path[basic] (1-1) edge node[sloped,above] {\large $2,0,2$} (6-1);

\path[basic] (2-1) edge node[sloped,above] {\large $3,0,0$} (4-1); \path[basic] (2-1) edge node[sloped,above, near end] {\large $ 2,0,0 $} (5-1);

\path[nobasic,name path=arc-32] (3-1) edge node[sloped,above] {\large $3,2 $} (2-1); \path[basic] (3-1) edge node[sloped,above] {\large $3,0,2$} (7-1);

\path[nobasic,name path=arc-43] (4-1) edge node[sloped,above, near end] {\large $ 3,1 $} (3-1); \path[basic] (4-1) edge node[sloped,above] {\large $ 2,0,0 $} (6-1); \path[basic] (4-1) edge node[sloped,above,near start] {\large $ 3,0,3 $} (e-1);

\path[nobasic,name path=arc-57] (5-1) edge node[sloped,above] {\large $ 4,2 $} (7-1); \path[basic] (5-1) edge node[sloped,above, near end] {\large $ 4,0,4 $} (e-1);

\path[basic] (6-1) edge node[sloped,above,near start] {\large $ 4,0,4 $} (5-1); \path[nobasic,name path=arc-67] (6-1) edge node[sloped,above, near end] {\large $ 3,1 $} (7-1);

\path[basic] (7-1) edge node[sloped,above] {\large $ 9,0,2 $} (e-1);

\draw[mincut,name path=mincut] (12,-4) .. controls (12,0) and (8,2) .. (9,6);

% testing to draw dot at intersections

\fill[red,name intersections={of=mincut and arc-67}] (intersection-1) circle (2pt) node {1};

\end{tikzpicture}

\end{document}

John W. de Burgh
  • 1,245
  • 1
  • 7
  • 15

1 Answers1

1

Apparently edges "mincut" and "arc-67" doesn't intersect ("mincut" cross "arc-67" to close of its end or at its end, this is not good visible). You need to move mincut curve a bit more to left.

In your MWE many edges are drawn twice, also style definitions are inconsistent. So I took a liberty and recode your MWE (from scratch). You may liked obtained result:

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, automata,
                intersections,
                positioning,
                quotes
                }

\begin{document} \begin{tikzpicture}[auto, node distance = 20mm and 30mm, dot/.style = {circle, fill=red, inner sep=2pt, node contents={}}, every state/.style = {circle, draw=red, very thick}, every edge/.style = {draw=blue, line width=1pt, -Stealth, shorten >=2pt, shorten <=2pt, }, every edge quotes/.style = {auto, sloped, inner sep=2pt}, every label/.style = {rectangle, inner sep=2pt, font=\large}, mincut/.style = {draw=green!40!black, line width=3pt, dashed} ] \node (1-1) [state, label=left:{$(4^-,3)$}] {1}; \node (4-1) [state, right=of 1-1, label=above left:{$(2^+,3)$}] {4}; \node (2-1) [state, above=of 4-1, label=above:{$(s^+,3)$}] {2}; \node (3-1) [state, right=of 2-1] {3}; \node (5-1) [state, below=of 3-1, label=left:{$(2^+,2)$}] {5}; \node (6-1) [state, below right=of 4-1, label=below:{$(4^+,2)$}] {6}; \node (7-1) [state, right=of 5-1] {7}; % \node (e-1) [state, accepting, below= of 7-1] {e}; \node (s-1) [state, accepting, left=of 1-1 |- 2-1, label={$(-,\infty)$}] {s}; % edges \path (s-1) edge ["{$5,0,5$}"] (1-1) (s-1) edge ["{$3,0,0$}"] (2-1) (s-1) edge [bend left, "{$3,0,2$}"] (3-1) (s-1) edge [out=270,in=180, "{$2,0,2$}"] (6-1)

(1-1) edge [dashed, &quot;{$2,2$}&quot;] (2-1)
    (1-1) edge [&quot;{$3,0,3$}&quot;] (4-1)
    (1-1) edge [&quot;{$2,0,2$}&quot;] (6-1)

    (2-1) edge [&quot;{$3,0,0$}&quot;] (4-1)
    (2-1) edge [near end, &quot;{$2,0,0$}&quot;] (5-1)

    (3-1) edge [&quot;{$3,0,2$}&quot;]    (7-1)

(3-1) edge [name path=arc-32, dashed, near end, "{$3,2$}"] (2-1) (3-1) edge ["{$3,0,2$}"] (7-1)

    (4-1) edge [&quot;{$2,0,0$}&quot;]    (6-1)
    (4-1) edge [near start, &quot;{$3,0,3$}&quot;] (e-1)

(4-1) edge [name path=arc-43, dashed, near start, "{$3,1$}"] (3-1) (5-1) edge [name path=arc-57, dashed, "{$4,2 $}"] (7-1) (5-1) edge [near end, "{$ 4,0,4$}"] (e-1)

    (6-1) edge [near start, &quot;{$ 4,0,4$}&quot;] (5-1)
(6-1) edge [name path=arc-67, dashed, near end,
            &quot;{$3,1$}&quot;]   (7-1)

    (7-1) edge [&quot;{$9,0,2$}&quot;] (e-1);

%
\path[mincut,name path=mincut] (9,-3.3) .. controls +(2,4) and +(-1,-4) .. (6,5); % intersections \begin{scope}[every label/.append style = {font=\small\bfseries, text=red}] \fill[name intersections={of=mincut and arc-67}] (intersection-1) node[dot,label=left: 1]; \fill[name intersections={of=mincut and arc-57}] (intersection-1) node[dot,label=2]; \fill[name intersections={of=mincut and arc-43}] (intersection-1) node[dot,label=3]; \fill[name intersections={of=mincut and arc-32}] (intersection-1) node[dot,label=above right:4]; \end{scope} \end{tikzpicture} \end{document}

enter image description here

Zarko
  • 296,517