2

I would like to create the following kind of vertex in my graph:

  • Circular node
  • One label inside (similar to vstyle = Normal)
  • One label out and under (similar to Welsh)

It seems that it isn't a builtin option for that and I have also found some related questions (see here and here).

The problem is both answers do that for every vertex (and also I don't get the matrix part in the second question) but I would like my graph to look like a directed normal with only a few nodes being doubly labeled.

I would also like to add that I am not set on using tikz-graph but from my search it looked liked a good place to start.

Thanks

EDIT 1: Here's an example of what I want (please ignore the funny looking C-D edge)

enter image description here

emphasized text All the vertices have a label center inside but A and B have one more outside label.

EDIT 2: Based on @Zarko's comments I add a try which fixes the nodes but breaks the edges

\documentclass{article}
\usepackage{tkz-graph}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}
  \node[circle, draw, label=below:X]  at (0,0){A};
  \node[circle, draw, label=below:Y]  at (1,0){B};
  \Vertex[x=1,y=1]{C}
  \Vertex[x=2,y=0]{D}
  \tikzstyle{LabelStyle}=[sloped]
  \tikzstyle{EdgeStyle}=[post]
  \Edge(C)(D)
\end{tikzpicture}
\end{figure}

\end{document}
7
  • Please, clarify your description with some sketch what you after. From description can be concluded that the first link gives exactly what you like to have.
    – Zarko
    Apr 1, 2022 at 9:56
  • @Zarko I will try to add the sketch. In the meantime, the first link doesn't give what I want because a) it is about forests and I want general graphs and b) it applies to every node while I want only a few of them. (There's the issue that the labels are up and not down but I guess that's an easy fix)
    – cgss
    Apr 1, 2022 at 10:02
  • Than show us what you try so far to get a "general" graph.
    – Zarko
    Apr 1, 2022 at 10:08
  • @Zarko Added a sketch. Is it more clear now?
    – cgss
    Apr 1, 2022 at 10:10
  • In general you can define node as \node[circle, draw, fill=<color>, label=above:<label>] at (<coordinate>) {<node content>); if node is circle.
    – Zarko
    Apr 1, 2022 at 10:11

1 Answer 1

5

As starting point:

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,  % define arrows head styles
                positioning}  % for nodes positioning

\begin{document}
    \begin{tikzpicture}[
node distance = 12mm and 9mm,
     C/.style = {circle, draw, semithick,
                 minimum size = 8mm,
                 label=#1},
every edge/.style = {draw, -Straight Barb},
                        ]
\node (n1) [C=below:X]  {A};
\node (n2) [C=below:Y, right=of n1]  {B};
\node (n3) [C, right=of n2]             {C};
%
\path   (n1) edge   (n2)
        (n2) edge   (n3);
    \end{tikzpicture}
\end{document}

enter image description here

For details about tikz see package documentation (it is huge!), part III contain basic description.Examples of tikz images you can find on site texample.net.

3
  • Thanks Zarko. 2 quick question before accepting your answer. I haven't yet encountered tikz as a class. It doesn't need anything more in my preamble right(I mean when using a different doc class). And secondly I can't find Straight Barb. What is it?
    – cgss
    Apr 1, 2022 at 10:55
  • @cgss, see edited answer.
    – Zarko
    Apr 1, 2022 at 11:02
  • 1
    Straight Barb is the arrow tip style.
    – SebGlav
    Apr 1, 2022 at 14:24

You must log in to answer this question.

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