1

I would like to learn to create this kind of pictures as below with colored vertices in Tikz. The vertex sizes can be the same. This is a graph demonstration (CC BY-SA 3.0) for equivalence classes originating from here. Can this be done with default Tikz or do I need some package?

How can you create colorful undirected graphs like the below in Tikz?

enter image description here

1
  • 2
    Yes it can be done. – user10274 Jun 2 '16 at 13:22
1

I create below two small examples separated by three dots. You can change the line width similarly to the color with the command line width such as \draw [color=red, line width=0.5mm] (0,0)--(1,1).

enter image description here

MWE

\begin{tikzpicture}
\tikzstyle{every node}=[draw, circle, fill=black, inner sep=0pt,minimum size=3pt] 
\draw (0,4) node(6){} -- (2,3) node(5){} -- (2,1) node(4){} -- (0,0) node(3){} -- (-2,1) node(2){} -- (-2,3) node(1){} -- cycle;
\draw[color=red] (1) -- (3);
\end{tikzpicture}
...

\begin{tikzpicture}
\tikzstyle{every node}=[draw, circle, fill=black, inner sep=0pt,minimum size=3pt] 
\draw[color=green] (2,0) node(4){H4} -- (7,-5) -- (7,-7) -- (6,-8) -- (4,-8) -- (3,-7) -- (3,-6) node(44){H4};

\draw[color=red] (0,-5) node (3){H3} -- (12,-5) node (33){H3};
\draw[color=yellow] (5,-1) node (1){H1} -- (5,-10) node (11){H1};
\draw[color=orange] (10,0) node (2){H2} -- (2,-9) node (22){H2};

\draw[color=pink] (12,-3) node(5){H5} -- (8,-7) node (5){H5};

\end{tikzpicture}

P.s. I am unsure which packages I am using because using Tikz and loading my default preamble. If you know whether this requires any packages besides tikz, do not hesitate to comment or add the info.

3
  • I am having an inheritance issue to place the two tikz pictures side-by-side, aspiring thoughts welcome in chat :) – hhh Jun 2 '16 at 13:52
  • Honestly, how long does it take you to make a new file, add \documentclass{article}\usepackage{tikz}\begin{document}<your code>\end{document} and try? (No other packages are required.) – Torbjørn T. Jul 2 '16 at 15:55
  • Regarding the problem you mention in chat, do you show the code for the problem anywhere? – Torbjørn T. Jul 2 '16 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.