3

I have the following graph:

\begin{figure}
\begin{tikzpicture}
\node[shape=circle,draw=black,minimum size=1cm] (0) at (0,0) {$0$};   
\node[shape=circle,draw=black,minimum size=1cm] (11) at  (-1,0) {$-1$};  
\node[shape=circle,draw=black,minimum size=1cm] (12) at  (-2,0) {$-2$};  
\node[shape=circle,draw=black,minimum size=1cm] (13) at (-3,0) {$-3$}; 
\node[shape=circle,draw=black,minimum size=1cm] (14) at (-4,0) {$-4$}; 
\node[shape=circle,draw=black,minimum size=1cm] (1) at  (1,0) {$1$};  
\node[shape=circle,draw=black,minimum size=1cm] (2) at  (2,0) {$2$};  
\node[shape=circle,draw=black,minimum size=1cm] (3) at (3,0) {$3$}; 
\node[shape=circle,draw=black,minimum size=1cm] (4) at (4,0) {$4$}; 

\draw (0) -- (1);  
\draw (2) -- (1);  
\draw (3) -- (2);  
\draw (4) -- (3); 
\draw (0) --(11);  
\draw (11) -- (12);  
\draw (12) -- (13);  
\draw (13) --(14);    
\end{tikzpicture}
\end{figure}

In this picture, the edges between the nodes are not visible. How to make the edges visible?

Secondly I want the nodes to continue in both direction, i.e. I want the graph to be an infinite graph on both sides. Can someone please help me on how to make the graph infinite?

I would be grateful if someone could fix this.

3

The reason why you can´t see the lines is because your nodes are too big. Change the minimum size=1cm to minimum size=0.5cm and you will see them.

I do not know what you mean with "make the graph infinite" but here is what I think you might want to achieve: I used a foreach loop so you don´t have to copy and paste your code over and over again.

\documentclass[border=3.5mm]{standalone}
\usepackage{tikz}
\pgfdeclarelayer{bg}
\pgfsetlayers{bg,main}
\begin{document} 

$\raisebox{2ex}{$\cdots$}$
\begin{tikzpicture}
    \foreach\x in {-10,...,-5,-4,-3,-2,-1,0,1,2,3,4,5,...,10}
    \draw [] (\x,0) circle (1 mm) node[fill=white,draw=black,circle,inner sep=2pt,minimum size=0.8cm] {\x};
     
    \begin{pgfonlayer}{bg}
    \draw[red ] (0,0)
        \foreach \x in {-10,...,-5,-4,-3,-2,-1,0,1,2,3,4,5,...,10}
        {-- (\x,0)};
        \end{pgfonlayer}
    \end{tikzpicture}
    $\raisebox{2ex}{$\cdots$}$
\end{document}

enter image description here

5
  • I mean the nodes to continue on both sides, i mean to add \cdots on both sides, for example, suppose the nodes are all integers with $-6$ joined to $-7$, $-7$ joined to $-8$ and so on, is it possible to do it
    – Math_Freak
    Mar 22 '21 at 3:25
  • @Math_Freak I edited my answer.
    – Roland
    Mar 22 '21 at 3:47
  • Thanks for the answer, is it possible to draw the dots from the middle of the node?Also the nodes containing negative coordinates are larger than nodes with positive coordinates, how to fix this?
    – Math_Freak
    Mar 22 '21 at 4:28
  • In my example I cannot see any difference between negative and positive nodes in size. Their dimensions can be changed with adjusting inner sep=<value> and minimum size=<value>. I added a possible solution to center the dots to my answer.
    – Roland
    Mar 22 '21 at 5:14
  • Thanks a lot mate,, +1 for you
    – Math_Freak
    Mar 22 '21 at 5:27

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.