我想画一个图,附上粗略的符号图。这里 $K_m$ 表示一个有 $m$ 个顶点的完整图。$K_m$ 的每个顶点都与 $K_n$ 的每个顶点以及 $K_1$ 相连。为简单起见,可以取 $m=5$ 和 $n=3$。我尝试从中取一个例子Texample.net但失败了。
新编辑:
现在我已经尝试关注米=8和n=3。我可以进一步缩短代码吗?
\documentclass{article}
\usepackage{amsmath,graphicx,tikz,tikz-3dplot}
\usetikzlibrary{shapes,calc,positioning,graphs,graphs.standard}
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\foreach \x in {1,...,8}{%
\node[shape=circle,draw,fill=black,inner sep=1pt] (d\x) at (0,{4*cos((\x-1)*45)},{4*sin((\x-1)*45)}) {};}
\node[shape=circle,draw,fill=black,inner sep=1pt] (O) at (-5,0,0){};
\foreach \x in {1,2,3}{%
\node[shape=circle,draw,fill=black,inner sep=1pt] (t\x) at (5,{4*cos((\x-1)*120)},{4*sin((\x-1)*120)}) {};}
\foreach \d in {1,...,8}{
\draw[color=blue] (O)--(d\d);}
\foreach \x in {1,...,8}{
\foreach \y in {\x,...,8}{
\draw[color=red] (d\x)--(d\y);}}
\foreach \x in {1,...,8}{
\foreach \y in {1,2,3}{
\draw[color=green] (d\x)--(t\y);}}
\foreach \x in {1,2,3}{
\foreach \y in {\x,...,3}{
\draw[color=black] (t\x)--(t\y);}}
\end{tikzpicture}
\caption{Graph $\Gamma_1$}
\end{figure}
\end{document}
答案1
这是一个可能的解决方案,tikz-3dplot
用于绘制 3D 图表。可以通过标记坐标来删除坐标。可以通过设置来调整不同的透视角度
\tdplotsetmaincoords{90}{120}
代码
\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{shapes,calc,positioning}
\tdplotsetmaincoords{70}{110}
\begin{document}
\begin{tikzpicture}[scale=2, tdplot_main_coords,axis/.style={->,dashed},thick]
\node[shape=circle,draw,fill=black,inner sep=1pt] (O) at (0,-2,2){};
\draw[axis] (0, 0, 0) -- (3, 0, 0) node [right] {$X$};
\draw[axis] (0, 0, 0) -- (0, 3, 0) node [above] {$Y$};
\draw[axis] (0, 0, 0) -- (0, 0, 3) node [above] {$Z$};
\coordinate (d1) at (1,0,3){};
\coordinate (d2) at (-1,0,3){};
\coordinate (d3) at (0,0,1){};
\coordinate (d4) at (0,0,4){};
\draw [] (d1) -- (d4)--(d2)--(d3)--cycle;
\coordinate (t1) at (1,2.,4){};
\coordinate (t2) at (-1,2,4){};
\coordinate (t3) at (0,2,2){};
\draw (t1)--(t2)--(t3)--cycle;
\foreach \d in {1,2,3,4}{
\draw[color=red] (O)--(d\d);
}
\foreach \i in {1,2,3,4}{
\foreach \j in {1,2,3}{
\draw[color=red] (d\i)--(t\j);
}}
\node at (0,0,0.5) (l){$\mathbf K_m$};
\node at (O |- l) {$\mathbf K_1$};
\node at (t3 |- l) {$\mathbf K_n$};
\end{tikzpicture}
\end{document}
答案2
TikZ 支持基本的 3d 坐标系。您可以通过解释 z 向量相对于 x 和 y 的含义来更改视图(请参阅手册)。因此,您可以从此开始;
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[ultra thick] (2,-1,0) coordinate (a)
-- (2.5,0.3,0.5) coordinate (b)
-- (2,0.5,0) coordinate (c)
-- (1.5,0.2,0.2) coordinate (d)
-- cycle;
\draw[ultra thick] (3.7,-0.5,0.5) coordinate (e)
-- (4.5,0.3,0.5) coordinate (f)
-- (3.5,0.5,0) coordinate (g)
-- cycle;
\draw \foreach\x in{a,...,d}{(0,0,0)-- (\x)};
\draw \foreach\x in{a,...,d}{\foreach\y in{e,f,g}{(\x)-- (\y)}};
\draw (a)--(c) (b)--(d);
\end{tikzpicture}
\end{document}