Sorry if this has been asked before, but I couldn't find something to address my particular issue. Everything I have seen (e.g. this) seems to assume particular pattern to the edges and nodes.
I have an arbitrary unweighted, undirected graph that I would like to draw. It can be specified entirely from its set of edges. I'm not especially fussed on the particular layout or look. I would prefer that the nodes are circles with the labels in the middle and that the graph grows out more horizontally than vertically to take better advantage of the page, but beyond that, I'm not really bothered and would prefer to leave as much as possible up to the layout engine.
The edges in question are [(1,2); (2,3); (3,4); (3,5); (3,6); (4, 7); (5, 9); (6,7); (6,10); (8,9); (9,10);]
I'm interested in TikZ solutions primarily, but if someone wants to suggest something else I'm listening.
I looked at the TikZ manual (both the big separate sections on graph drawing that I could find), as well as this blog post and other questions on this site, but nothing I have found seems to address the question for an arbitrary graph.
I have tried a couple of solutions already based on what I saw, but neither of them worked. Firstly, based on this question (I only included the first few edges while I experimented with this approach):
\documentclass{article}
\usepackage{tikz}
\usepackage{shellesc}
\usetikzlibrary{graphdrawing,graphs,external}
\tikzexternalize
\begin{tikzpicture}[->,auto,main node/.style={circle,draw},node distance=3cm]
\node[main node] (1) {1};
\node[main node] (2) {2};
\node[main node] (3) {3};
\node[main node] (4) {4};
\node[main node] (5) {5};
\node[main node] (6) {6};
\node[main node] (7) {7};
\node[main node] (8) {8};
\node[main node] (9) {9};
\node[main node] (10) {10};
\path[]
(1) edge node (2)
(2) edge node (3)
(3) edge node (4);
\end{tikzpicture}
\end{document}
but that seems to draw everything on top of each other. Secondly, and initially promisingly, based on something I saw somewhere (but forget where):
\documentclass{article}
\usepackage{tikz}
\usepackage{shellesc}
\usetikzlibrary{graphdrawing,graphs,external}
\tikzexternalize
\begin{tikzpicture}[nodes={shape=circle,draw}]
\graph {
1 -- 2,
2 -- 3,
3 -- 4,
3 -- 5,
3 -- 6,
4 -- 7,
5 -- 9,
6 -- 7,
6 -- 10,
8 -- 9,
9 -- 10,
};
\end{tikzpicture}
\end{document}
but that seems to work well for the first two edges, then everything else just grows down the page with edges running right through all the other nodes.
Clearly, I am doing something badly wrong but I can't work out what. I would very much appreciate it if someone could please explain to me what I'm doing wrong and/or how I could actually achieve what I'm looking for (either by posting a sample or pointing me to the right place to look - nothing I have found gives a clear answer to this particular question). Thanks.
below
etc. If you omit them, of course everything will be drawn on top of each other since, if you do not specify coordinates, TikZ will take them to be(0,0)
. Could you perhaps explain or sketch a bit what you want to achieve? Also I am wondering how importantexternalize
andshellesc
are here.