使边缘弯曲

使边缘弯曲

我需要使边缘 (2,4') 弯曲,以便它不与 (2,2') 重叠。我该怎么做?

\documentclass[10pt]{article}
\usepackage{amstext}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{tikz}
\usepackage{filecontents}
\usepackage{graphicx}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{positioning,arrows.meta,patterns,shadows}
\usetikzlibrary{graphs,graphs.standard,quotes}
\usetikzlibrary{shapes.arrows,patterns}
\usetikzlibrary{positioning,shapes,calc,decorations.pathmorphing}

\begin{document}

\begin{tikzpicture}[scale = 0.6]
\tikzset{% This is the style settings for nodes
    cli/.style={circle,ball color=black,inner sep=0pt,minimum size=5pt],draw, general shadow={fill=gray!60,shadow xshift=1pt,shadow yshift=-1pt}},
    c1/.style={very thick,green},
    c2/.style={very thick,blue}}
\node[cli] (v1) at (-2,-2) {};
\node[cli] (v2) at (-2,2) {}; 
\node[cli] (v3) at (2,2) {};

\node[cli] (v1p) at (1,-3) {};
\node[cli] (v2p) at (1,-1) {}; 
\node[cli] (v3p) at (3,-1) {};
\node[cli] (v4p) at (3,-3) {};

\node (l1) at (-2.75,-2) {$1$};
\node (l2) at (-2.75,2) {$2$}; 
\node (l3) at (2.75,2) {$3$};
\node (l1p) at (0.85,-0.25) {$2'$};
\node (l2p) at (0.85,-3.75) {$1'$}; 
\node (l3p) at (3.15,-0.25) {$3'$};
\node (l4p) at (3.15,-3.75) {$4'$};

\draw[c1] (v2) -- (v1);
\draw[c1] (v2) -- (v3);
\draw[c2] (v1) -- (v3); 

\draw[c1] (v2p) -- (v1p);
\draw[c1] (v2p) -- (v3p);
\draw[c2] (v1p) -- (v4p);
\draw[c1] (v4p) -- (v3p);
\draw[c2] (v4p) -- (v2p); 
\draw[c2] (v1p) -- (v3p); 

\draw[c2] (v2) -- (v1p);
\draw[c2] (v2) -- (v2p);
\draw[c2] (v2) -- (v3p);
\draw[c2] (v2) -- (v4p);

\draw[c1] (v3) -- (v1p);
\draw[c1] (v3) -- (v2p);
\draw[c1] (v3) -- (v3p);
\draw[c1] (v3) -- (v4p);

\end{tikzpicture}

\end{document}

答案1

您想使用路径操作bend right的选项,to如下所示:

\draw[c2] (v2) to[bend right] (v4p);
\draw[c2] (v2) to[bend right=90, looseness=2] (v4p);

有关如何使用它们的更多信息,请参阅始终加载的手册topaths图书馆。当然,你总是可以使用.. controls路径操作但图书馆的钥匙topaths通常会使事情变得容易得多。

因为您正在加载该graphs库,所以请允许我在示例中使用它。

代码

\documentclass[tikz]{standalone}
\usetikzlibrary{graphs, positioning, quotes, shadows}
\tikzset{
  graphs/tikz/.code=\tikzset{#1},
  math nodes/.style={execute at begin node=$, execute at end node=$}}
\begin{document}
\begin{tikzpicture}[
  cli/.style={
    circle, ball color=black, inner sep=0pt, minimum size=5pt, draw,
    general shadow={fill=gray!60, shadow xshift=1pt, shadow yshift=-1pt}},
  c1/.style={very thick, green},
  c2/.style={very thick, blue},
  every label quotes/.append style={math nodes},
  on grid, node distance=42mm, new set=primes,
]
\graph[no placement, nodes=cli, typeset=]{
  1["1" left],
  2["2" left,   above=of 1],
  3["3" right,  right=of 2],
  @[coordinate, below=of 3],
  {[tikz={node distance=10.5mm and 10.5mm, label distance=4pt}, nodes={set=primes}]
    1'["1'" below, below  left=of @],
    2'["2'" above, above  left=of @],
    3'["3'" above, above right=of @],
    4'["4'" below, below right=of @]
  },
  {[edges=c1]
    1 -- 2 -- 3 -- (primes),
    1' -- 2' -- 3' -- 4'
  },
  {[edges=c2]
    1 -- 3,
    1' -- 4',
    4'[> bend right=10],
    2 -- (primes)
  }
};
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述

相关内容