| Function | Usage | Comment |
| sort | [Y,ind]=sort(X) | ind has subscripts so that Y(i)=X(ind(i)) for all i |
| Colon : | pos(e,:)=[i,j] | record the position of some edge |
| & | (Gsize>e) & (C(rowcurr)==C(colcurr)) | Logical AND |
| if ... end; | if (outlevel>3), display(H); end; | note comma! terminate with end; |
| if else end; | if (e<=Gsize), ...; else ...; end; | |
| for | for e=0:Gsize, ...; end; | Loop with known number of repeats |
| while | while (Gsize>e), ... end; | note comma! terminate loop with end; |
| zeros | zeros(m,n) | Create m by n matrix of zeros |
| Optional | For prettification, debugging | |
| int2str | int2str(e) | convert int to string for use with disp |
| disp | disp(['number of edges', int2str(e)]) | alternative to display function |
| help | eg help elmat, help sort ... | get help on matrices, sorting, ... anything |
function T=kruskal(n,W,outlevel)
taking three parameters with the following description.Before asking me, look up the MATLAB help pages! And revise the description of Kruskal's algorithm and the examples that we did in class.