1

I have following 2 questions.

First of all i am telling that the MWE provided by me is partially edited from geogebra.

Question: 1 In this graph i would like add direction (like >) on all four edges.

Question: 2 Is there any other way to draw same graph? Because i want to learn new techniques for drawing.

MWE:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgf}
\usepackage{pgfplots}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}
  \draw [line width=1pt] (0,0)-- (5,0);
  \draw [line width=1pt] (5,0)-- (5,5);
  \draw [line width=1pt] (5,5)-- (0,5);
  \draw [line width=1pt] (0,5)-- (0,0);
  \draw [fill=black] (0,0) circle (1.8pt);
  \draw[color=black] (0.05,-0.45) node {$D$};
  \draw [fill=black] (5,0) circle (1.8pt);
  \draw[color=black] (5.05,-0.45) node {$C$};
  \draw [fill=black] (5,5) circle (1.8pt);
  \draw[color=black] (5.0,5.4) node {$B$};
  \draw [fill=black] (0,5) circle (1.8pt);
  \draw[color=black] (0.05,5.4) node {$A$};
  \draw[color=black] (2.5,-0.45) node {$e_3$};
  \draw[color=black] (5.4,2.7) node {$e_2$};
  \draw[color=black] (2.5,5.3) node {$e_1$};
  \draw[color=black] (-0.4,2.7) node {$e_4$};
 \end{tikzpicture}

\end{document}
2

2 Answers 2

1

Your image can be drawn on many different way. One way, using tikz libraries positioning and quotes gives relative short code:

\documentclass[tikz, margin=3pt]{standalone}
\usetikzlibrary{arrows.meta,
                positioning,
                quotes}

\begin{document}
    \begin{tikzpicture}[
dot/.style = {circle, fill, inner sep=1.6pt, outer sep=0pt,
              node contents={}},
every edge/.style = {draw, line width=1pt,-{Stealth[angle=60:3pt 3]}}
                    ]
\node (d) [dot,label=below:$D$];
\node (c) [dot,label=below:$C$, right=5 of d];
\node (b) [dot,label=$B$,above=5.4 of c];
\node (a) [dot,label=$A$,above=5.4 of d];
%
\draw   (a) edge ["$e_1$"]  (b)
        (b) edge ["$e_2$"]  (c)
        (c) edge ["$e_3$"]  (d)
        (d) edge ["$e_4$"]  (a);
    \end{tikzpicture}
\end{document}

enter image description here

Nodes in above image is positioned relative to previous node, labels of vertices are written as label to nodes defining them, for edge labels is used library quotes. Arrows are added by defining eh edges, which connect vertices

Edit:

ups, I forgot on arrows ... now added.

0

Here is one way.

enter image description here

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[thick,>=stealth,
n/.style={circle,fill,minimum size=2mm,inner sep=0}]
\def\a{5}
\path
(0,0)      node[n] (A) {} node[above left]  {A}
++(0:\a)   node[n] (B) {} node[above right] {B}   
++(-90:\a) node[n] (C) {} node[below right] {C} 
++(180:\a) node[n] (D) {} node[below left]  {D};
\draw[->] (A)--(B) node[midway,above] {$e_1$};
\draw[->] (B)--(C) node[midway,right] {$e_2$};
\draw[->] (C)--(D) node[midway,below] {$e_3$};
\draw[->] (D)--(A) node[midway,left]  {$e_4$};
\end{tikzpicture}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .