Code covered by the BSD License
icosahedron(g) --- overwrite g with the icosahedron graph
0001 function icosahedron(g) 0002 % icosahedron(g) --- overwrite g with the icosahedron graph 0003 0004 resize(g,12); 0005 clear_edges(g); 0006 full(g); 0007 0008 elist = [ 0009 1 2 0010 1 3 0011 1 4 0012 1 5 0013 1 9 0014 2 3 0015 2 5 0016 2 6 0017 2 7 0018 3 7 0019 3 8 0020 3 9 0021 4 5 0022 4 9 0023 4 10 0024 4 12 0025 5 6 0026 5 10 0027 6 7 0028 6 10 0029 6 11 0030 7 8 0031 7 11 0032 8 9 0033 8 11 0034 8 12 0035 9 12 0036 10 11 0037 10 12 0038 11 12 0039 ]; 0040 add(g,elist); 0041 0042 t0 = 0; 0043 t1 = -2*pi/3; 0044 t2 = 2*t1; 0045 0046 outer = [ 0047 sin(t0) cos(t0) 0048 sin(t1) cos(t1) 0049 sin(t2) cos(t2) 0050 ]; 0051 0052 hex = []; 0053 0054 for k=0:5 0055 hex = [hex; sin(-k*pi/3), cos(-k*pi/3)]; 0056 end 0057 0058 inner = outer*[cos(pi/3), sin(pi/3); -sin(pi/3), cos(pi/3)]; 0059 0060 0061 xy = [3*outer; hex; inner/3]; 0062 embed(g,xy) 0063 0064 0065
Contact us at files@mathworks.com