Advertisement
pdpd123

Untitled

Mar 13th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 1.99 KB | None | 0 0
  1. \documentclass{article}
  2. \usepackage{sagetex}
  3. \usepackage{tikz,tkz-graph,tkz-berge}
  4. \thispagestyle{empty}
  5. \begin{document}
  6. Here's a graph where you specify the position of the vertices. Note that the label is placed inside unless specified:\
  7. \begin{center}
  8. \begin{tikzpicture}[scale=1.5]
  9. \renewcommand*{\VertexLineWidth}{1pt}%vertex thickness
  10. \renewcommand*{\EdgeLineWidth}{1pt}% edge thickness
  11. \GraphInit[vstyle=Normal]
  12. \Vertex[Lpos=270,L= $v_1$ ,x=0,y=0]{R1}
  13. \Vertex[LabelOut,Lpos=270,L= $v_2$ ,x=0,y=2]{R2}
  14. \Vertex[LabelOut,Lpos=270,L= $v_3$ ,x=1,y=1]{R3}
  15. \Vertex[LabelOut,Lpos=270,L= $v_4$ ,x=2,y=1]{R4}
  16. \Vertex[LabelOut,Lpos=270,L= $v_5$ ,x=3,y=1]{R5}
  17. \Vertex[LabelOut,Lpos=270,L= $v_6$ ,x=4,y=1]{R6}
  18. \Vertex[LabelOut,Lpos=90,L= $v_7$ ,x=3,y=2]{R7}
  19. \Vertex[LabelOut,Lpos=90,L= $v_8$ ,x=4,y=2]{R8}
  20. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  21. \Edge (R3)(R4)
  22. \Edge (R3)(R1)
  23. \Edge (R2)(R3)
  24. \Edge (R5)(R4)
  25. \Edge (R5)(R6)
  26. \Edge (R5)(R7)
  27. \Edge (R6)(R8)
  28. \Edge (R7)(R8)
  29. \end{tikzpicture}
  30. \end{center}
  31.  
  32. But \textsf{Sage} has knowledge of graph theory and you can use it to specify graphs
  33. and determine various characteristics. For example:\
  34. \begin{sagesilent}
  35. H= graphs.PetersenGraph()
  36. H.set_latex_options(scale=3.5,graphic_size=(2.1,2.1))
  37. Chi = H.chromatic_number(algorithm="DLX")
  38. Beta = H.independent_set()
  39. \end{sagesilent}
  40. \noindent The Petersen graph below has $sage{H.order()}$ vertices and
  41. $sage{H.size()}$ edges.\
  42. \begin{center}
  43. \begin{tikzpicture}
  44. \GraphInit[vstyle=Normal]
  45. \SetVertexNormal[Shape=circle,LineWidth = 1pt]
  46. \tikzset{EdgeStyle/.append style = {color = blue!60, line width=1pt}}
  47. \sage{H}
  48. \end{tikzpicture}
  49. \end{center}
  50. \vspace{5pt}
  51. The chromatic number is $chi(G)=\sage{Chi}$ . The maximum size independent
  52. set is $beta(G)=\sage{len(Beta)}$ . One such set is $sage{Beta}$ . The
  53. maximum size clique has $omega(G)=\sage{H.clique_number()}$ vertices;
  54. e.g., $sage{H.clique_maximum()}$ . The diameter is $sage{H.diameter()}$
  55. and the radius is $sage{H.radius()}$ .
  56. \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement