-->m1 = rand(5,5) m1 = 0.2113249 0.6283918 0.5608486 0.2320748 0.3076091 0.7560439 0.8497452 0.6623569 0.2312237 0.9329616 0.0002211 0.6857310 0.7263507 0.2164633 0.2146008 0.3303271 0.8782165 0.1985144 0.8833888 0.312642 0.6653811 0.0683740 0.5442573 0.6525135 0.3616361 -->m2=m1+0.5 m2 = 0.7113249 1.1283918 1.0608486 0.7320748 0.8076091 1.2560439 1.3497452 1.1623569 0.7312237 1.4329616 0.5002211 1.185731 1.2263507 0.7164633 0.7146008 0.8303271 1.3782165 0.6985144 1.3833888 0.812642 1.1653811 0.5683740 1.0442573 1.1525135 0.8616361 -->m3=fix(m2) m3 = 0. 1. 1. 0. 0. 1. 1. 1. 0. 1. 0. 1. 1. 0. 0. 0. 1. 0. 1. 0. 1. 0. 1. 1. 0. -->m4=triu(m3,1) m4 = 0. 1. 1. 0. 0. 0. 0. 1. 0. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. -->a=m4 + m4' a = 0. 1. 1. 0. 0. 1. 0. 1. 0. 1. 1. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1. 0. 0. 0. -->// number of vertices -->[n, junk]=size(a); -->n n = 5. -->// number of edges -->e = sum(a)/2 e = 4. -->// degree sequence -->sort(sum(a, 'r')) ans = 3. 2. 2. 1. 0. -->//eigenvalues of the graph -->spec(a) ans = - 1.4811943 - 1. 0. 0.3111078 2.1700865 -->eigs(a) !--error 4 undefined variable : eigs -->// put it into the graph theory form -->sparse(a) ans = ( 5, 5) sparse matrix ( 1, 2) 1. ( 1, 3) 1. ( 2, 1) 1. ( 2, 3) 1. ( 2, 5) 1. ( 3, 1) 1. ( 3, 2) 1. ( 5, 2) 1. -->g = mat_2_graph(sparse(a), 0, 'node-node'); -->i = 0:1:4 i = 0. 1. 2. 3. 4. -->t = i .* 2*%pi/5 t = 0. 1.2566371 2.5132741 3.7699112 5.0265482 -->g('node_x') = 100*cos(t); -->g('node_y') = 100*sin(t); -->show_graph(g); -->xs2eps(0,'may18.eps'); -->plot_graph(g); -->graph_diameter(g) ans = 1.000E+09 -->h=graph_complement(g); -->graph_diameter(h) ans = 2. -->hamilton(h) !--error 9999 The graph must be directed at line 9 of function hamilton called by : hamilton(h) -->// Draw K_3,3 -->tail = [ 1 1 1 2 2 2 3 3 3]; head = [4 5 6 4 5 6 4 5 6]; -->k33=make_graph('k_3,3', 0, tail, head); !--error 39 incorrect number of arguments at line 4 of function make_graph called by : k33=make_graph('k_3,3', 0, tail, head); -->k33=make_graph('k_3,3', 0, 6, tail, head); -->k33('node_x') = [ 100 100 100 300 300 300]; -->k33('node_y') = [ 100 200 300 100 200 300]; -->show_graph(k33); -->diary(0);