-2

For my project in machine learning, I want to draw in LaTex a Graph with a common vertex Like this example: How can I do it, please? enter image description here

Alex
  • 79
  • 5
  • 2
    Welcome! For machine learning the graph will surely have a purpose. It is much better to have some idea how to systematically generate the graph than to just produce it brute force. –  May 14 '20 at 08:22
  • 2
    Welcome to TeX - LaTeX! try to put together a minimal working example (MWE) – Alessandro Cuttin May 14 '20 at 08:51
  • 1
    Does this have a follow up at https://tex.stackexchange.com/questions/545572/how-can-draw-to-the-following-code ? – albert May 22 '20 at 16:38
  • 5
    Why did you vandalize your own question? – leandriis May 22 '20 at 16:55
  • 5
    Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 4.0 license for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, consider taking a look at: How does deleting work? – Glorfindel May 22 '20 at 16:58
  • 1
    Your "unaccepting answer" games will certainly not help others, in particular not other newcomers. I think that the "accept an answer" "feature" of this site is anyway a wrong concept, and your actions give this thought even more weight. –  May 22 '20 at 17:07

1 Answers1

5

This is a start. Drawing a graph with a common vertex is as simple as saying

 {subgraph I_n [n=12,radius=2.5cm, counterclockwise,phase=105] -- 
    x}

where I_n is a standard graph that (in this usage) puts the nodes on an circle with equal distances. We can specify the number of nodes, the radius and the phase. If you want to see which node lives where, comment out [empty nodes].

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{graphs}
\usetikzlibrary{graphs.standard}
\usetikzlibrary{shapes.misc}
\begin{document}
\begin{tikzpicture}
\begin{scope}[nodes={circle, draw,minimum size=1.8em}]
 \graph[empty nodes] { 
  {subgraph I_n [n=12,radius=2.5cm, counterclockwise,phase=105] -- 
    x[label={[cross out,draw,minimum size=1em,thick]center:{}}]}; 
  1-- 2, 5-- 6, 7--8, 11 -- 12};
 \path (-{5*cos(15)},0) node (L){} ({5*cos(15)},0) node (R){};
\end{scope}
\draw (3) node{$a$}-- node[auto,swap]{$e$}(L) node{$b$} -- (4) node{$c$} (9) -- (R) -- (10);
\end{tikzpicture}
\end{document}

enter image description here

The graph draws most of what seems to be needed, the additional lines can either be drawn inside the \graph command or just be added to the tikzpicture. Some parts of your drawing are unreadable but adding them is easy.

  • 1
    @Alex I added an example. You can say \path (<start>) -- node[auto]{<label>} (<target>); and if you add swap as in the example the one will be on the other side. There are many variations and there is also the quotes library. –  May 14 '20 at 16:25
  • @Alex You get a letter x with x[label={center:{$x$}}] instead of x[label={[cross out,draw,minimum size=1em,thick]center:{}}] but please understand that it is not the purpose of this post to convert your instructions into TeX code. Rather, the model of this site is as follows: one can ask a well-defined question, and get an answer to this question. If an answer answers the original question, one can accept it by clicking on the check mark left of it. All further requests should be done in separate, well-defined questions. –  May 16 '20 at 21:52