.png)
내 질문은
그래프에 자체 루프와 평행 에지를 어떻게 그릴 수 있나요? 나는 비머에서 일하고 있어요
정점 V_1의 자체 루프
V_2와 V_3 사이의 평행 모서리
작은 질문 하나, 그림의 중심을 맞추는 방법
MWE
\documentclass[12pt,fleqn]{beamer}
\usetheme{AnnArbor}
\usepackage{setspace}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage{pgf,tikz,pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}
\usecolortheme{beaver}
\usefonttheme{professionalfonts} % using non standard fonts for beamer
\usefonttheme{serif} % default family is serif
\addtobeamertemplate{frametitle}{}{\vspace{-0.4em}} % decrease
\begin{document}
\begin{frame}[t]
\begin{tikzpicture}
\draw[line width=0.5pt] (0.0,3.0) -- (3.0,3.0);
\draw[line width=0.5pt] (3.0,3.0) -- (3.0,0.0);
\draw[line width=0.5pt] (3.0,0.0) -- (0.0,0.0);
\draw[line width=0.5pt] (0.0,0.0) -- (0.0,3.0);
\draw [fill=black] (0,3) circle (1.5pt);
\draw[color=black,above] (0.0,3.10) node {$v_1$};
\draw [fill=black] (3,3) circle (1.5pt);
\draw[color=black,above] (3.0,3.10) node {$v_2$};
\draw [fill=black] (3,0) circle (1.5pt);
\draw[color=black,below] (3.0,-0.10) node {$v_3$};
\draw [fill=black] (0,0) circle (1.5pt);
\draw[color=black,below] (0.0,-0.10) node {$v_4$};
\end{tikzpicture}
\end{frame}
\end{document}
답변1
라이브러리를 사용하면 automata
(답변: +1의 @js bibra와 유사) arrows.meta
화살표의 경우 평행 화살표 대신 구부러진 화살표가 사용되며 프리앰블에서 beamer
( xcolor
, )에 의해 로드된 패키지가 제거되고 프레젠테이션( ) 또는 amsmath
의미가 없습니다. setspace
최신 LaTeX 기본 기능( [utf]{inputenc}
)이 포함되어 있습니다.
\documentclass[12pt,fleqn]{beamer}
\usetheme{AnnArbor}
\usecolortheme{beaver}
\usefonttheme{professionalfonts} % using non standard fonts for beamer
\usefonttheme{serif} % default family is serif
\addtobeamertemplate{frametitle}{}{\vspace{-0.4em}} % decrease
%\usepackage{setspace}
%\usepackage{amsmath}
%\usepackage[utf8]{inputenc}
\usepackage{pgfplots} % it load tikz and pgf too
\pgfplotsset{compat=1.17}
\usepackage{mathrsfs}
\usetikzlibrary{arrows.meta, automata,
positioning,
shadows}
\begin{document}
\begin{frame}
\begin{center}
\begin{tikzpicture}[
node distance = 22mm and 22mm,
state/.append style = {circle, draw=orange, fill=orange,
minimum size=1.2em},
every edge/.style = {draw, -Stealth, semithick}
]
\begin{scope}[nodes=state]
\node (n1) {$v_1$};
\node (n2) [right=of n1] {$v_2$};
\node (n3) [below=of n2] {$v_3$};
\node (n4) [left =of n3] {$v_4$};
\end{scope}
\path (n3) edge (n4)
(n4) edge (n1)
(n1) edge [loop above,looseness=15] (n1)
(n1) edge (n2)
(n2) edge [bend left=15] (n3)
(n3) edge [bend left=15] (n2)
;
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
답변2
다음 줄을 추가하세요
\path
(v1) edge [->,loop above] node {} (v1);
직전에 \endtikzpicture
편집 - 관심을 가질 수 있고 편집/수정할 수 있는 대체 솔루션
\documentclass[12pt,fleqn]{beamer}
\usetheme{AnnArbor}
\usepackage{setspace}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage{pgf,tikz,pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
%\usetikzlibrary{arrows}
%\usetikzlibrary{decorations.markings, shapes,positioning,arrows.meta,bending,automata}
\usetikzlibrary {arrows.meta,automata,positioning,shadows,calc}
\usecolortheme{beaver}
\usefonttheme{professionalfonts} % using non standard fonts for beamer
\usefonttheme{serif} % default family is serif
\addtobeamertemplate{frametitle}{}{\vspace{-0.4em}} % decrease
\newcommand\DoubleLine[7][4pt]{%
\path(#2)--(#3)coordinate[at start](h1)coordinate[at end](h2);
\draw[#4]($(h1)!#1!90:(h2)$)-- node [auto=left] {#5} ($(h2)!#1!-90:(h1)$);
\draw[#6]($(h1)!#1!-90:(h2)$)-- node [auto=right] {#7} ($(h2)!#1!90:(h1)$);
}
\begin{document}
\begin{frame}[t]
\begin{center}
\begin{tikzpicture}[
->,
>={Stealth[round]},
shorten >=1pt,
auto,
node distance=2.8cm,
on grid,
semithick,
every state/.style={
fill=red,
draw=none,
circular drop shadow,
text=white
}
]
\node[state] (A) {$v_1$};
\node[state] (B) [right=of A] {$v_2$};
\node[state] (D) [below=of A] {$v_4$};
\node[state] (C) [below=of B] {$v_3$};
\path (A) edge (B)
(C)edge(D)
(D)edge(A)
(A) edge [loop above] (A)
;
\DoubleLine{B}{C}{<-,very thick,black}{}{->,very thick,red}{}
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
이중 화살표 정의는 여기에서 가져옵니다.