📄 3.txt
字号:
% Create a transition matrix by hand
%
matrix = ...
[ 1 2 Inf Inf
Inf Inf 3 3
1 Inf Inf Inf
1 Inf Inf Inf
];
n_node = size(matrix , 1);
% Convert the matrix to Graphviz source code
%
fid = fopen('graph.dot', 'w');
fprintf(fid, 'digraph{\n');
for i=1:n_node
for j=1:n_node
if matrix(i,j) ~= Inf
fprintf(fid, '\"%d\" -> \"%d\" [label=\"%f\"] ; \n', ...
i, j, matrix(i,j) );
end
end
end
fprintf(fid, '}\n');
fclose(fid);
% Draw the graph into an EPS file
%
system('dot -Tps graph.dot -o graph.eps');
% Found and print all cycles
%
for i = 1:n_node
[path, cost] = dijkstra(i,i,matrix);
fprintf(2, 'Cycle from %d -> %d, cost=%f, path is:', ...
i, i, cost);
disp(path)
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -