In the blue graph at the left there are 5 connections. From this graph one can create sub-graphs using for instance 3 of the connections. There would be a total of 10 combinations.
Is there a smart way to create and draw these combinations? Probably by using \foreach
.
\documentclass[border=5pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{positioning,matrix,shapes,arrows,calc}
\begin{document}
\begin{tikzpicture}[>=stealth',auto,node distance=2cm,
thick,main node/.style={circle,draw,font=\sffamily\Large\bfseries},dashnode/.style={circle,draw,dashed,font=\sffamily\Large\bfseries}]
\node[main node,blue] at (0, 0) (1) {1};
\node[main node,blue] at (1, 1) (2) {2};
\node[main node,blue] at (1, -1) (3) {3};
\node[main node,blue] at (2, 0) (4) {4};
\draw [blue] (1) -- (2);
\draw [blue] (1) -- (3);
\draw [blue] (2) -- (4);
\draw [blue] (2) -- (3);
\draw [blue] (3) -- (4);
\node[main node] at (3, 0) (1) {1};
\node[main node] at (4, 1) (2) {2};
\node[main node] at (4, -1) (3) {3};
\node[main node] at (5, 0) (4) {4};
\foreach \k in {(1) -- (2),(2) -- (3),(2) -- (4)} {
\draw \k ;
}
\node[main node] at (6, 0) (1) {1};
\node[main node] at (7, 1) (2) {2};
\node[main node] at (7, -1) (3) {3};
\node[main node] at (8, 0) (4) {4};
\foreach \k in {(1) -- (3),(2) -- (3),(3) -- (4)} {
\draw \k ;
}
\end{tikzpicture}
\end{document}
EDIT
After the very helpful comments from @Excelsior the problem has been codes as:
\documentclass[border=5pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{positioning,matrix,shapes,arrows,calc}
\begin{document}
% \begin{tikzpicture}[>=stealth',auto,node distance=2cm,
% thick,main node/.style={circle,draw,font=\sffamily\Large\bfseries},dashnode/.style={circle,draw,dashed,font=\sffamily\Large\bfseries}]
% \node[main node,blue] at (0, 0) (1) {1};
% \node[main node,blue] at (1, 1) (2) {2};
% \node[main node,blue] at (1, -1) (3) {3};
% \node[main node,blue] at (2, 0) (4) {4};
% \draw [blue] (1) -- (2);
% \draw [blue] (1) -- (3);
% \draw [blue] (2) -- (4);
% \draw [blue] (2) -- (3);
% \draw [blue] (3) -- (4);
% \node[main node] at (3, 0) (1) {1};
% \node[main node] at (4, 1) (2) {2};
% \node[main node] at (4, -1) (3) {3};
% \node[main node] at (5, 0) (4) {4};
% \foreach \k in {(1) -- (2),(2) -- (3),(2) -- (4)} {
% \draw \k ;
% }
% \node[main node] at (6, 0) (1) {1};
% \node[main node] at (7, 1) (2) {2};
% \node[main node] at (7, -1) (3) {3};
% \node[main node] at (8, 0) (4) {4};
% \foreach \k in {(1) -- (3),(2) -- (3),(3) -- (4)} {
% \draw \k ;
% }
% \end{tikzpicture}
\begin{tikzpicture}[
>=stealth', auto, node distance=2cm, thick,
main node/.style={circle, draw, font=\sffamily\Large\bfseries}, dashnode/.style={circle,draw,dashed,font=\sffamily\Large\bfseries}]
\node[main node,blue] at (0, 0) (1-0) {1};
\node[main node,blue] at (1, 1) (2-0) {2};
\node[main node,blue] at (1,-1) (3-0) {3};
\node[main node,blue] at (2, 0) (4-0) {4};
\draw [blue] (1-0) -- (2-0);
\draw [blue] (1-0) -- (3-0);
\draw [blue] (2-0) -- (4-0);
\draw [blue] (2-0) -- (3-0);
\draw [blue] (3-0) -- (4-0);
\foreach [evaluate=\i as \x using {3*(\i)}] \i in {1,...,11} {
\foreach \n in {1,...,4}{
\node[main node] at ($ (\n-0) + (\x,0) $) (\n-\i) {\n};
}
}
% node system 1
\foreach \k in {(1-1) -- (2-1),
(2-1) -- (3-1),
(2-1) -- (4-1)} {
\draw \k ;
}
% node system 2
\draw (1-2) -- (2-2);
\draw (2-2) -- (3-2);
\draw (3-2) -- (4-2);
\end{tikzpicture}
\end{document}
With the following result: