SHARE
TWEET

Untitled

a guest Jun 25th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. documentclass{standalone}
  2. usepackage{tikz}
  3. tikzstyle{graph}=[
  4.   every node/.style={circle,fill=black,inner sep=0pt,minimum width=8pt},
  5.   every path/.style={thick}
  6. ]
  7. begin{document}
  8. begin{tikzpicture}[graph]
  9. foreach i [evaluate=i as a using 90-(i-1)*360/5] in {1,...,5} {
  10.   node (oi) at (a:2) {};
  11.   node (ii) at (a-36:0.7) {};
  12. }
  13. draw (o1) -- (o2) -- (o3) -- (o4) -- (o5) -- (o1);
  14. draw (i1) -- (i2) -- (i3) -- (i4) -- (i5) -- (i1);
  15. draw (o1) -- (i3); draw (o2) -- (i1); draw (o5) -- (i5);
  16. draw[bend left] (o3) to (i4);
  17. draw[bend right] (o4) to (i2);
  18. end{tikzpicture}
  19. end{document}
  20.      
  21. documentclass{standalone}
  22. usepackage{tikz}
  23. usetikzlibrary{intersections}
  24. tikzstyle{graph}=[
  25.   every node/.style={circle,fill=black,inner sep=0pt,minimum width=8pt},
  26.   every path/.style={thick},
  27.   crossing/.style={rectangle,fill=red,inner sep=0pt,minimum size=4pt}
  28. ]
  29. begin{document}
  30. begin{tikzpicture}[graph]
  31. foreach i [evaluate=i as a using 90-(i-1)*360/5] in {1,...,5} {
  32.   node (oi) at (a:2) {};
  33.   node (ii) at (a-36:0.7) {};
  34. }
  35. draw (o1) -- (o2) -- (o3) -- (o4) -- (o5) -- (o1);
  36. draw[name path=p1] (i1) -- (i2) -- (i3) -- (i4) -- (i5) -- (i1);
  37. draw[name path=p2] (o1) -- (i3);
  38. draw (o2) -- (i1); draw (o5) -- (i5);
  39. draw[name path=p3,bend left] (o3) to (i4);
  40. draw[name path=p4,bend right] (o4) to (i2);
  41. path [name intersections={of=p1 and p2}] (intersection-1) node[crossing] {};
  42. path [name intersections={of=p3 and p4}] (intersection-1) node[crossing] {};
  43. end{tikzpicture}
  44. end{document}
  45.      
  46. newcommand*edge[1][]{draw[edge,#1]}
  47.      
  48. newcounter{ngraphpaths}
  49. newcounter{ncrossings}
  50.      
  51. edge/.append style={increment_ngraphpaths,name path global={cross_pthevalue{ngraphpaths}}},
  52. increment_ngraphpaths/.code={addtocounter{ngraphpaths}{1}},
  53.      
  54. execute at begin picture={setcounter{ngraphpaths}{0}setcounter{ncrossings}{0}},
  55.      
  56. execute at end picture={%
  57. ifnum value{ngraphpaths}>1
  58.   pgfmathtruncatemacroaend{value{ngraphpaths}-1}
  59.   foreach a in {1,...,aend}{
  60.     pgfmathtruncatemacrobstart{a+1}
  61.     foreach b in {bstart,...,value{ngraphpaths}}
  62.       path [name intersections={of={cross_pa} and {cross_pb},name=i,total=t}]
  63.         ifnum t>0
  64.           foreach s in {1,...,t}{(i-s) node[crossing] {}}
  65.           pgfextra{addtocounter{ncrossings}{t}}
  66.         fi;
  67.   }
  68. fi
  69. typeout{showcrossings: found thevalue{ncrossings} crossing(s)}}
  70.      
  71. documentclass{standalone}
  72. usepackage{tikz}
  73. usetikzlibrary{intersections}
  74. tikzstyle{graph}=[
  75.   every node/.style={circle,fill=black,inner sep=0pt,minimum width=8pt},
  76.   edge/.style={thick},
  77.   crossing/.style={rectangle,fill=red,inner sep=0pt,minimum size=4pt}
  78. ]
  79. newcommand*edge[1][]{draw[edge,#1]}
  80. newcounter{ngraphpaths}
  81. newcounter{ncrossings}
  82. tikzstyle{showcrossings}=[
  83.   edge/.append style={increment_ngraphpaths,name path global={cross_pthevalue{ngraphpaths}}},
  84.   increment_ngraphpaths/.code={addtocounter{ngraphpaths}{1}},
  85.   execute at begin picture={setcounter{ngraphpaths}{0}setcounter{ncrossings}{0}},
  86.   execute at end picture={%
  87. ifnum value{ngraphpaths}>1
  88.   pgfmathtruncatemacroaend{value{ngraphpaths}-1}
  89.   foreach a in {1,...,aend}{
  90.     pgfmathtruncatemacrobstart{a+1}
  91.     foreach b in {bstart,...,value{ngraphpaths}}
  92.       path [name intersections={of={cross_pa} and {cross_pb},name=i,total=t}]
  93.         ifnum t>0
  94.           foreach s in {1,...,t}{(i-s) node[crossing] {}}
  95.           pgfextra{addtocounter{ncrossings}{t}}
  96.         fi;
  97.   }
  98. fi
  99. typeout{showcrossings: found thevalue{ncrossings} crossing(s)}}
  100. ]
  101. begin{document}
  102. begin{tikzpicture}[graph,showcrossings]
  103. foreach i [evaluate=i as a using 90-(i-1)*360/5] in {1,...,5} {
  104.   node (oi) at (a:2) {};
  105.   node (ii) at (a-36:0.7) {};
  106. }
  107. edge (o1) -- (o2) -- (o3) -- (o4) -- (o5) -- (o1);
  108. edge (i1) -- (i2) -- (i3) -- (i4) -- (i5) -- (i1);
  109. edge (o1) -- (i3);
  110. edge (o2) -- (i1); edge (o5) -- (i5);
  111. edge[bend left] (o3) to (i4);
  112. edge[bend right] (o4) to (i2);
  113. end{tikzpicture}
  114. end{document}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top