-->pwd ans = / -->cd /Users/bellenot/scilab/graph ans = /Users/bellenot/scilab/graph -->ls ans = !test1.out ! ! ! !su09.sci ! ! ! !petersen.graph ! ! ! !p3.edgelist ! ! ! !p3.adjlist ! ! ! !ico2.edgelist ! ! ! !ico2.adjlist ! ! ! !ico1.edgelist ! ! ! !ico1.adjlist ! ! ! !gui.sce ! ! ! !g258.edgelist ! ! ! !g257.edgelist ! ! ! !g256.edgelist ! ! ! !g255.edgelist ! -->exec('su09.sci'); -->g1=readedgelist('g251.edgelist') ta = 24. 1. n = 2. g1 = graph name : Untitled version : 5.0.1 oriented : no number of nodes : 8 number of edges : 12 -->show_graph(g1) ans = 0. -->show_graph(circ(g1)) ans = 0. -->show_graph(el(g1)) ans = 0. -->show_graph(eaxy(g1,2 3)) !--error 3 Waiting for right parenthesis. -->show_graph(eaxy(g1,2, 3)) ans = 0. -->show_graph(ea(g1)) ans = 0. -->show_graph(eaxy(g1,2, 3)) ans = 0. -->show_graph(circ(g1)) ans = 0. -->show_graph(el(g1,2,3)) !--error 58 Wrong number of input arguments: Arguments are : g -->show_graph(elxy(g1,2,3)) ans = 0. -->gplot3d(g1) -->// question why no picture? -->spec(graph_2_mat(g1)) !--error 246 Function not defined for given argument type(s), check arguments or define function %sp_spec for overloading. -->spec(full(graph_2_mat(g1))) !--error 20 Wrong type for argument -2521078: Square matrix expected. -->spec(full(graph_2_mat(g1,'node=nde'))) !--error 10000 Second argument must be "node-node" or "node-arc" at line 36 of function graph_2_mat called by : spec(full(graph_2_mat(g1,'node=nde'))) -->spec(full(graph_2_mat(g1,'node-node'))) ans = - 2.4142136 - 1.7320508 - 1. - 1. 0.4142136 1. 1.7320508 3. -->g5=readedgelist('g255.edgelist') ta = 24. 1. n = 2. g5 = graph name : Untitled version : 5.0.1 oriented : no number of nodes : 8 number of edges : 12 -->show_graph(circ(g5)) ans = 0. -->show_graph(circ(g5)) ans = 0. -->show_graph(el(g5)) ans = 0. -->spec(full(graph_2_mat(g1,'node-node'))) ans = - 2.4142136 - 1.7320508 - 1. - 1. 0.4142136 1. 1.7320508 3. -->spec(full(graph_2_mat(g5,'node-node'))) ans = - 2.4142136 - 1.7320508 - 1. - 1. 0.4142136 1. 1.7320508 3. -->t1=prufer([1 1 1 1]); -->show_graph(circ(t1)) ans = 0. -->exec('su09.sci'); Warning : redefining function: circ . Use funcprot(0) to avoid this message Warning : redefining function: prufer . Use funcprot(0) to avoid this message Warning : redefining function: readedgelist . Use funcprot(0) to avoid this message Warning : redefining function: ea . Use funcprot(0) to avoid this message Warning : redefining function: eaxy . Use funcprot(0) to avoid this message Warning : redefining function: el . Use funcprot(0) to avoid this message Warning : redefining function: elxy . Use funcprot(0) to avoid this message Warning : redefining function: gplot3d . Use funcprot(0) to avoid this message -->t1=prufer([1 1 1 1]); leaf = 106. 2. 3. 4. 5. 6. leaf = 106. 106. 3. 4. 5. 6. leaf = 106. 106. 106. 4. 5. 6. leaf = 106. 106. 106. 106. 5. 6. -->a !--error 4 Undefined variable: a -->exec('su09.sci'); Warning : redefining function: prufer . Use funcprot(0) to avoid this message -->t1=prufer([1 1 1 1]); leaf = 106. 2. 3. 4. 5. 6. leaf = 106. 106. 3. 4. 5. 6. leaf = 106. 106. 106. 4. 5. 6. leaf = 106. 106. 106. 106. 5. 6. leaf = column 1 to 5 106. 106. 106. 106. 106. column 6 6. leaf = column 1 to 5 106. 106. 106. 106. 106. -->[li j] = min([106 106 3]) j = 3. li = 3. -->[li j] = min([106 106 5]) j = 3. li = 5. -->w= [ 4 5 1 3 4 6 1] Warning : redefining function: w . Use funcprot(0) to avoid this message w = 4. 5. 1. 3. 4. 6. 1. -->find(w==1) ans = 3. 7. -->w(find(w==1))=13 w = 4. 5. 13. 3. 4. 6. 13. -->t1 t1 = graph name : Untitled version : 5.0.1 oriented : no number of nodes : 6 number of edges : 5 -->spec(full(graph_2_mat(t1,'node-node'))) ans = - 2.236068 - 2.776D-16 0. 0. 0. 2.236068 -->show_graph(el(t1)) ans = 0. -->show_graph(ea(t1)) ans = 0. -->scf() ans = Handle of type "Figure" with properties: ======================================== children: "Axes" figure_position = [200,200] figure_size = [614,556] axes_size = [610,460] auto_resize = "on" viewport = [0,0] figure_name = "Graphic window number %d" figure_id = 0 info_message = "" color_map= matrix 32x3 pixmap = "off" pixel_drawing_mode = "copy" immediate_drawing = "on" background = -2 visible = "on" rotation_style = "unary" event_handler = "" event_handler_enable = "off" user_data = [] tag = "" -->gplot3(t1) !--error 4 Undefined variable: gplot3 -->gplot3d(t1) -->clf() -->gplot3d(g1) -->gplot3d(g5) -->clf() -->gplot3d(g5) -->t2=prufer([1 4 1 5 2 3 3 5]); leaf = column 1 to 5 110. 110. 110. 110. 110. column 6 to 10 6. 7. 8. 9. 10. leaf = column 1 to 5 110. 110. 110. 110. 110. column 6 to 10 110. 7. 8. 9. 10. leaf = column 1 to 5 110. 110. 110. 4. 110. column 6 to 10 -->clf() -->gplot3d(t2) -->show_graph(ea(t2)) ans = 0. -->show_graph(el(t2)) ans = 0. -->show_graph(circ(q(3)) !--error 3 Waiting for right parenthesis. -->show_graph(circ(q(3))) ans = 0. -->show_graph(circ(q(4))) ans = 0. -->show_graph(circ(q(5))) ans = 0. -->show_graph(circ(q(5))) ans = 0. -->exec('egraph.sci') -->// This should iterate for both 2d and 3d. -->// Assumes the eigenvector is non-zero in position (1,1). -->function [evalue, evector] = maxEvalue(A) -->n = size(A,2); -->X = zeros(n,1); X(1,1) = 1; -->OldX = X; -->done = %f; -->eps = 1E-7; -->i = 1; -->while ~done --> OldX = X; --> X = A*X; --> N = norm(X); --> X = X/N; --> X = sign(X(1,1))*X; --> if n == 2, --> printf("L = %f, V = [%f; %f], i = %d\n", N, X(1,1), X(2,1), i); --> elseif n==3, --> printf("L = %f, V = [%f; %f; %f], i = %d\n", N, X(1,1), X(2,1), X(3,1), i); --> end; --> done = (norm(OldX-X) < eps); --> i = i+1; -->end; -->next = A*X; -->evalue = next(1,1)/X(1,1); -->evector = X; -->endfunction; -->function [evalue, evector] = minEvalue(A) -->if det(A) == 0 --> [N, X] = maxEvalue(A); --> evalue = 0; --> evector = sign(X(2,1))*[X(2,1); -X(1,1)]; -->else --> [N, X] = maxEvalue(inv(A)); --> evalue = 1/N; --> evector = X; -->end -->endfunction; -->function [evalue, evector] = nearEvalue(A,s) -->[N, X] = maxEvalue(inv(A-s*eye(A))); -->evalue = s+1/N; -->evector = X; -->endfunction; -->// Assumes A is 2x2 symmetric matrix -->function t = eplot2d(A) -->[Lmax, Emax] = maxEvalue(A); -->[Lmin, Emin] = minEvalue(A); -->plotquad(A); -->eArrow(Lmax,Emax); -->if Lmin == 0 --> eArrow(Lmax/4,Emin); -->else --> eArrow(Lmin,Emin); -->end; -->t = Lmin*Lmax; -->if t == 0 --> printf("Two Parallel Lines\n"); -->elseif t > 0 --> printf("Ellipse\n"); -->else --> printf("Hyperbola\n"); -->end -->if Lmin == 0, --> lim = 2/sqrt(abs(Lmax)); -->else --> lim = 2/sqrt(abs(Lmin)); -->end; -->if t <= 0, --> square(-lim,-lim,lim,lim); -->end; -->endfunction; -->// Plot Quad plots the conic section for a given 2x2 symmetric matrix -->// It assumes that the matrix is A and it is already defined. -->// It plots black curves -->function plotquad(A); -->theta = 0:%pi/50:2*%pi; // %pi is scilab for the constant pi -->n = size(theta,2); // theta is a 1 x n row vector -->x = zeros(theta); // x and y start as zero vectors -->y = zeros(theta); -->for i = 1:n, --> angle = theta(i); // this angle --> c = cos(angle); --> s = sin(angle); --> X = [ c, s ]; --> r = sqrt(1/abs(X*A*X')); // formula from section 4 --> x(i) = r*c; // r cos(theta) --> y(i) = r*s; -->end; -->plot(x,y,'k-'); -->a = gca(); a.isoview="on"; -->t="Conic for A = ["+string(A(1,1))+" "+string(A(1,2)) +"; "+string(A(2,1))+" "+string(A(2,2))+"]"; -->xtitle(t,"x","y"); -->endfunction; -->function eArrow(L,E) -->E= E/sqrt(abs(L)); -->xarrows([0,E(1,1)],[0,E(2,1)],1,5) // 5 red, 2 blue, 3 green -->endfunction; -->A=[2 1 ; 1 3]; X=[1,0] X = 1. 0. -->A=[2 1 ; 1 3]; X=[1;0] X = 1. 0. -->[L, E] = maxEvalue(A) L = 2.236068, V = [0.894427; 0.447214], i = 1 L = 3.162278, V = [0.707107; 0.707107], i = 2 L = 3.535534, V = [0.600000; 0.800000], i = 3 L = 3.605551, V = [0.554700; 0.832050], i = 4 L = 3.616203, V = [0.536875; 0.843661], i = 5 L = 3.617767, V = [0.529999; 0.847998], i = 6 L = 3.617995, V = [0.527363; 0.849640], i = 7 L = 3.618028, V = [0.526355; 0.850265], i = 8 L = 3.618033, V = [0.525969; 0.850504], i = 9 L = 3.618034, V = [0.525822; 0.850595], i = 10 L = 3.618034, V = [0.525766; 0.850629], i = 11 L = 3.618034, V = [0.525744; 0.850643], i = 12 L = 3.618034, V = [0.525736; 0.850648], i = 13 L = 3.618034, V = [0.525733; 0.850650], i = 14 L = 3.618034, V = [0.525732; 0.850650], i = 15 L = 3.618034, V = [0.525731; 0.850651], i = 16 L = 3.618034, V = [0.525731; 0.850651], i = 17 L = 3.618034, V = [0.525731; 0.850651], i = 18 E = 0.5257312 0.8506508 L = 3.6180338 -->[X,D] = spec(A) D = 1.381966 0. 0. 3.618034 X = - 0.8506508 0.5257311 0.5257311 0.8506508 -->plotquad(A) -->scf() ans = Handle of type "Figure" with properties: ======================================== children: "Axes" figure_position = [200,200] figure_size = [614,556] axes_size = [610,460] auto_resize = "on" viewport = [0,0] figure_name = "Graphic window number %d" figure_id = 0 info_message = "" color_map= matrix 32x3 pixmap = "off" pixel_drawing_mode = "copy" immediate_drawing = "on" background = -2 visible = "on" rotation_style = "unary" event_handler = "" event_handler_enable = "off" user_data = [] tag = "" -->plotquad(A) -->[L2,E2]=minEvalue(A) L = 0.632456, V = [0.948683; -0.316228], i = 1 L = 0.707107, V = [0.894427; -0.447214], i = 2 L = 0.721110, V = [0.868243; -0.496139], i = 3 L = 0.723241, V = [0.857493; -0.514496], i = 4 L = 0.723553, V = [0.853282; -0.521450], i = 5 L = 0.723599, V = [0.851658; -0.524097], i = 6 L = 0.723606, V = [0.851036; -0.525107], i = 7 L = 0.723607, V = [0.850798; -0.525493], i = 8 L = 0.723607, V = [0.850707; -0.525640], i = 9 L = 0.723607, V = [0.850672; -0.525696], i = 10 L = 0.723607, V = [0.850659; -0.525718], i = 11 L = 0.723607, V = [0.850654; -0.525726], i = 12 L = 0.723607, V = [0.850652; -0.525729], i = 13 L = 0.723607, V = [0.850651; -0.525730], i = 14 L = 0.723607, V = [0.850651; -0.525731], i = 15 L = 0.723607, V = [0.850651; -0.525731], i = 16 L = 0.723607, V = [0.850651; -0.525731], i = 17 E2 = 0.8506508 - 0.5257311 L2 = 1.381966 -->eplot2d(A) L = 2.236068, V = [0.894427; 0.447214], i = 1 L = 3.162278, V = [0.707107; 0.707107], i = 2 L = 3.535534, V = [0.600000; 0.800000], i = 3 L = 3.605551, V = [0.554700; 0.832050], i = 4 L = 3.616203, V = [0.536875; 0.843661], i = 5 L = 3.617767, V = [0.529999; 0.847998], i = 6 L = 3.617995, V = [0.527363; 0.849640], i = 7 L = 3.618028, V = [0.526355; 0.850265], i = 8 L = 3.618033, V = [0.525969; 0.850504], i = 9 L = 3.618034, V = [0.525822; 0.850595], i = 10 L = 3.618034, V = [0.525766; 0.850629], i = 11 L = 3.618034, V = [0.525744; 0.850643], i = 12 L = 3.618034, V = [0.525736; 0.850648], i = 13 L = 3.618034, V = [0.525733; 0.850650], i = 14 L = 3.618034, V = [0.525732; 0.850650], i = 15 L = 3.618034, V = [0.525731; 0.850651], i = 16 L = 3.618034, V = [0.525731; 0.850651], i = 17 L = 3.618034, V = [0.525731; 0.850651], i = 18 L = 0.632456, V = [0.948683; -0.316228], i = 1 L = 0.707107, V = [0.894427; -0.447214], i = 2 L = 0.721110, V = [0.868243; -0.496139], i = 3 L = 0.723241, V = [0.857493; -0.514496], i = 4 L = 0.723553, V = [0.853282; -0.521450], i = 5 L = 0.723599, V = [0.851658; -0.524097], i = 6 L = 0.723606, V = [0.851036; -0.525107], i = 7 L = 0.723607, V = [0.850798; -0.525493], i = 8 L = 0.723607, V = [0.850707; -0.525640], i = 9 L = 0.723607, V = [0.850672; -0.525696], i = 10 L = 0.723607, V = [0.850659; -0.525718], i = 11 L = 0.723607, V = [0.850654; -0.525726], i = 12 L = 0.723607, V = [0.850652; -0.525729], i = 13 L = 0.723607, V = [0.850651; -0.525730], i = 14 L = 0.723607, V = [0.850651; -0.525731], i = 15 L = 0.723607, V = [0.850651; -0.525731], i = 16 L = 0.723607, V = [0.850651; -0.525731], i = 17 Ellipse ans = 4.9999999 -->clf -->eplot2d([2 1; 1 -3]) L = 2.236068, V = [0.894427; 0.447214], i = 1 L = 2.280351, V = [0.980581; -0.196116], i = 2 L = 2.361551, V = [0.747409; 0.664364], i = 3 L = 2.492748, V = [0.866186; -0.499722], i = 4 L = 2.667268, V = [0.462139; 0.886807], i = 5 L = 2.848242, V = [0.635861; -0.771804], i = 6 L = 2.993313, V = [0.167012; 0.985955], i = 7 L = 3.087265, V = [0.427556; -0.903989], i = 8 L = 3.139903, V = [0.015566; -0.999879], i = 9 L = 3.167005, V = [0.305887; -0.952068], i = 10 L = 3.180348, V = [0.106999; -0.994259], i = 11 L = 3.186774, V = [0.244844; -0.969563], i = 12 L = 3.189834, V = [0.150439; -0.988619], i = 13 L = 3.191284, V = [0.215506; -0.976502], i = 14 L = 3.191970, V = [0.170895; -0.985289], i = 15 L = 3.192293, V = [0.201579; -0.979472], i = 16 L = 3.192446, V = [0.180524; -0.983571], i = 17 L = 3.192518, V = [0.194994; -0.980804], i = 18 L = 3.192552, V = [0.185061; -0.982727], i = 19 L = 3.192568, V = [0.191885; -0.981417], i = 20 L = 3.192576, V = [0.187199; -0.982322], i = 21 L = 3.192579, V = [0.190418; -0.981703], i = 22 L = 3.192581, V = [0.188208; -0.982129], i = 23 L = 3.192582, V = [0.189726; -0.981837], i = 24 L = 3.192582, V = [0.188683; -0.982038], i = 25 L = 3.192582, V = [0.189399; -0.981900], i = 26 L = 3.192582, V = [0.188907; -0.981995], i = 27 L = 3.192582, V = [0.189245; -0.981930], i = 28 L = 3.192582, V = [0.189013; -0.981975], i = 29 L = 3.192582, V = [0.189172; -0.981944], i = 30 L = 3.192582, V = [0.189063; -0.981965], i = 31 L = 3.192582, V = [0.189138; -0.981950], i = 32 L = 3.192582, V = [0.189087; -0.981960], i = 33 L = 3.192582, V = [0.189122; -0.981954], i = 34 L = 3.192582, V = [0.189098; -0.981958], i = 35 L = 3.192582, V = [0.189114; -0.981955], i = 36 L = 3.192582, V = [0.189103; -0.981957], i = 37 L = 3.192582, V = [0.189111; -0.981956], i = 38 L = 3.192582, V = [0.189105; -0.981957], i = 39 L = 3.192582, V = [0.189109; -0.981956], i = 40 L = 3.192582, V = [0.189106; -0.981957], i = 41 L = 3.192582, V = [0.189108; -0.981956], i = 42 L = 3.192582, V = [0.189107; -0.981956], i = 43 L = 3.192582, V = [0.189108; -0.981956], i = 44 L = 3.192582, V = [0.189107; -0.981956], i = 45 L = 3.192582, V = [0.189108; -0.981956], i = 46 L = 3.192582, V = [0.189107; -0.981956], i = 47 L = 3.192582, V = [0.189108; -0.981956], i = 48 L = 3.192582, V = [0.189107; -0.981956], i = 49 L = 3.192582, V = [0.189108; -0.981956], i = 50 L = 0.451754, V = [0.948683; 0.316228], i = 1 L = 0.454007, V = [0.995037; 0.099504], i = 2 L = 0.455096, V = [0.968277; 0.249878], i = 3 L = 0.455616, V = [0.989151; 0.146904], i = 4 L = 0.455862, V = [0.975970; 0.217905], i = 5 L = 0.455979, V = [0.985576; 0.169231], i = 6 L = 0.456034, V = [0.979238; 0.202715], i = 7 L = 0.456060, V = [0.983714; 0.179741], i = 8 L = 0.456072, V = [0.980698; 0.195531], i = 9 L = 0.456078, V = [0.982797; 0.184692], i = 10 L = 0.456081, V = [0.981368; 0.192138], i = 11 L = 0.456082, V = [0.982355; 0.187025], i = 12 L = 0.456083, V = [0.981680; 0.190537], i = 13 L = 0.456083, V = [0.982145; 0.188125], i = 14 L = 0.456083, V = [0.981826; 0.189782], i = 15 L = 0.456083, V = [0.982045; 0.188644], i = 16 L = 0.456083, V = [0.981895; 0.189426], i = 17 L = 0.456083, V = [0.981998; 0.188889], i = 18 L = 0.456083, V = [0.981927; 0.189258], i = 19 L = 0.456083, V = [0.981976; 0.189004], i = 20 L = 0.456083, V = [0.981943; 0.189178], i = 21 L = 0.456083, V = [0.981966; 0.189059], i = 22 L = 0.456083, V = [0.981950; 0.189141], i = 23 L = 0.456083, V = [0.981961; 0.189085], i = 24 L = 0.456083, V = [0.981953; 0.189123], i = 25 L = 0.456083, V = [0.981958; 0.189097], i = 26 L = 0.456083, V = [0.981955; 0.189115], i = 27 L = 0.456083, V = [0.981957; 0.189102], i = 28 L = 0.456083, V = [0.981956; 0.189111], i = 29 L = 0.456083, V = [0.981957; 0.189105], i = 30 L = 0.456083, V = [0.981956; 0.189109], i = 31 L = 0.456083, V = [0.981957; 0.189106], i = 32 L = 0.456083, V = [0.981956; 0.189108], i = 33 L = 0.456083, V = [0.981956; 0.189107], i = 34 L = 0.456083, V = [0.981956; 0.189108], i = 35 L = 0.456083, V = [0.981956; 0.189107], i = 36 L = 0.456083, V = [0.981956; 0.189108], i = 37 L = 0.456083, V = [0.981956; 0.189107], i = 38 L = 0.456083, V = [0.981956; 0.189108], i = 39 L = 0.456083, V = [0.981956; 0.189107], i = 40 L = 0.456083, V = [0.981956; 0.189108], i = 41 Hyperbola ans = - 6.9999977 -->eplot2d([2 1; 1 0.5]) L = 2.236068, V = [0.894427; 0.447214], i = 1 L = 2.500000, V = [0.894427; 0.447214], i = 2 L = 2.236068, V = [0.894427; 0.447214], i = 1 L = 2.500000, V = [0.894427; 0.447214], i = 2 Two Parallel Lines ans = 0. -->clf -->eplot2d([2 1; 1 0.5]) L = 2.236068, V = [0.894427; 0.447214], i = 1 L = 2.500000, V = [0.894427; 0.447214], i = 2 L = 2.236068, V = [0.894427; 0.447214], i = 1 L = 2.500000, V = [0.894427; 0.447214], i = 2 Two Parallel Lines ans = 0. -->exec('SCI/etc/scilab.quit','errcatch',-1);quit;