Special Graphs

  1. A weighted graph is a graph in which edges are assigned numerical values called weights.

    Weights may represent distances, costs, times, or capacities.
    Each edge contains a numerical weight. For example, the edge between 1 and 2 has the weight of 5.

    Each edge contains a numerical weight. For example, the edge between $1$ and $2$ has the weight of $5$. Miriam Briskman, CC BY-NC 4.0.

    \documentclass[border=1pt]{standalone}
    \usepackage{tikz}
    
    \tikzset{
    vertex/.style={draw, circle, very thick, minimum size=1cm},
    edge/.style={very thick}
    }
    
    \begin{document}
    
    \begin{tikzpicture}
    
    \node[vertex] (v1) at (0,0) {$1$};
    \node[vertex] (v2) at (4,0) {$2$};
    \node[vertex] (v3) at (2,3) {$3$};
    
    \draw[edge] (v1) -- node[above] {$5$} (v2);
    \draw[edge] (v1) -- node[left] {$2$} (v3);
    \draw[edge] (v2) -- node[right] {$7$} (v3);
    
    \end{tikzpicture}
    
    \end{document}