当前位置:网站首页>Code source de la fonction [analogique numérique] MATLAB allcycles () (non disponible avant 2021a)
Code source de la fonction [analogique numérique] MATLAB allcycles () (non disponible avant 2021a)
2022-07-07 04:40:00 【Dream of Grass】
Matlaballcycles()
Code source de la fonction
Dans ce billet précédentTous les cercles dirigés d'un digraphe sont obtenus par le programme(Anneau dirigé)Et visualiserIl y a unallcycles
Fonctions,Cette fonction n'a que2021aC'est vrai.,SimatlabCette fonction ne peut pas être utilisée sans une version plus élevée,Donc pour que tout le monde puisse l'utiliser,J'ai misallcycles
Trouver la fonction intégrée et la partager avec tout le monde.
function [cycles, edgecycles] = allcycles(G, varargin)
% ALLCYCLES Compute all cycles in digraph
% CYCLES = ALLCYCLES(G) computes all the cycles in digraph G. CYCLES is a
% cell array in which CYCLES{
i} is a vector of numeric node IDs (if G
% does not have node names) or a cell array of character vectors (if G
% has node names). Each cycle in CYCLES begins with the smallest node
% index. If G is acyclic, then CYCLES is empty. The cycles are in
% lexicographical order.
%
% [CYCLES, EDGECYCLES] = ALLCYCLES(G) also returns a cell array
% EDGECYCLES in which EDGECYCLES{
i} contains the edges on the cycle
% CYCLES{
i} of G.
%
% [...] = ALLCYCLES(G, Name, Value) specifies one or more additional
% options using name-value pair arguments. The available options are:
%
% 'MaxNumCycles' - A scalar that specifies the maximum number
% of cycles in the output.
% 'MaxCycleLength' - A scalar that specifies the maximum cycle
% length of cycles in the output.
% 'MinCycleLength' - A scalar that specifies the minimum cycle
% length of cycles in the output.
%
% See also ISDAG, HASCYCLES, CYCLEBASIS, ALLPATHS
% Copyright 2020-2021 The MathWorks, Inc.
%
% Reference:
% Johnson, Donald B. "Finding all the elementary circuits of a directed
% graph." SIAM Journal on Computing 4.1 (1975): 77-84.
[maxNumCycles, maxCycleLength, minCycleLength] = parseInputs(varargin{
:});
if maxCycleLength < minCycleLength
cycles = cell(0, 1);
edgecycles = cell(0, 1);
return
end
try
if nargout < 2
cycles = allSimpleCycles(G.Underlying, maxNumCycles, maxCycleLength,...
minCycleLength);
else
[cycles, edgecycles] = allSimpleCycles(G.Underlying, maxNumCycles,...
maxCycleLength, minCycleLength);
end
catch e
if e.identifier == "MATLAB:nomem"
error(message('MATLAB:graphfun:allcycles:nomem'));
else
rethrow(e);
end
end
[names, hasNodeNames] = getNodeNames(G);
names = names.';
if hasNodeNames
for i = 1:size(cycles, 1)
cycles{
i} = names(cycles{
i});
end
end
end
function [maxNumCycles, maxCycleLength, minCycleLength] = parseInputs(varargin)
names = {
'MaxNumCycles', 'MaxCycleLength', 'MinCycleLength'};
maxNumCycles = Inf;
maxCycleLength = Inf;
minCycleLength = 1;
for i = 1:2:numel(varargin)
opt = validatestring(varargin{
i}, names);
if i+1 > numel(varargin)
error(message('MATLAB:graphfun:allcycles:KeyWithoutValue', opt));
end
switch opt
case 'MaxNumCycles'
maxNumCycles = varargin{
i+1};
validateattributes(maxNumCycles, {
'numeric'}, {
'scalar', 'real', 'nonnegative', 'integer'}, '', 'MaxNumCycles')
case 'MaxCycleLength'
maxCycleLength = varargin{
i+1};
validateattributes(maxCycleLength, {
'numeric'}, {
'scalar', 'real', 'positive', 'integer'}, '', 'MaxCycleLength')
case 'MinCycleLength'
minCycleLength = varargin{
i+1};
validateattributes(minCycleLength, {
'numeric'}, {
'scalar', 'real', 'positive', 'integer'}, '', 'MinCycleLength')
end
end
end
Un peu de fiction
Calculer toutes les périodes dans un digraphe
CYCLES
= ALLCYCLES
(G
)Calculer le digrapheG Tous les cycles de
Tableau de cellules,Parmi euxCYCLES
{ i
} Est un noeud numérique idVecteur de(SiG
Pas de nom de noeud ) Ou un tableau de cellules d'un vecteur de caractères (SiG
Nom du noeud). CYCLES
Chaque cycle commence au plus petit noeud
Index. SiG Est acyclique ,AlorsCYCLESVide. Le cycle est
Ordre de la lexicographie .
[CYCLES
, EDGECYCLES
] = ALLCYCLES
(G
) Renvoie également un tableau de cellules
EDGECYCLES
,Parmi euxEDGECYCLES
{ i
} Contient des bords sur la boucle
Cycle{- moi.}DeG.
[… = ALLCYCLES
(G
, Name
, Value
) Spécifiez une ou plusieurs valeurs supplémentaires
Utiliser le nom- Options pour les valeurs par rapport aux paramètres . Les options disponibles sont:
MaxNumCycles
- Un scalaire spécifiant le nombre maximum
Cycle de sortie.
MaxCycleLength
- Un scalaire spécifiant la période maximale
Longueur du cycle en sortie .
MinCycleLength
- Un scalaire spécifiant la période minimale
Longueur du cycle en sortie .
边栏推荐
- The worse the AI performance, the higher the bonus? Doctor of New York University offered a reward for the task of making the big model perform poorly
- Zero knowledge private application platform aleo (1) what is aleo
- 軟件測試之網站測試如何進行?測試小攻略走起!
- Data security -- 12 -- Analysis of privacy protection
- 案例大赏:英特尔携众多合作伙伴推动多领域AI产业创新发展
- Thesis landing strategy | how to get started quickly in academic thesis writing
- 抖音或将推出独立种草社区平台:会不会成为第二个小红书
- 【实践出真理】import和require的引入方式真的和网上说的一样吗
- Web3 社区中使用的术语
- 广告归因:买量如何做价值衡量?
猜你喜欢
NTU notes 6422quiz review (1-3 sections)
kivy教程之设置窗体大小和背景(教程含源码)
Surpassing postman, the new generation of domestic debugging tool apifox is elegant enough to use
mpf2_ Linear programming_ CAPM_ sharpe_ Arbitrage Pricin_ Inversion Gauss Jordan_ Statsmodel_ Pulp_ pLU_ Cholesky_ QR_ Jacobi
What if win11 pictures cannot be opened? Repair method of win11 unable to open pictures
[knife-4j quickly build swagger]
How to open win11 remote desktop connection? Five methods of win11 Remote Desktop Connection
Video fusion cloud platform easycvr video Plaza left column list style optimization
[ArcGIS tutorial] thematic map production - population density distribution map - population density analysis
测试/开发程序员怎么升职?从无到有,从薄变厚.......
随机推荐
Jetson nano配置pytorch深度学习环境//待完善
掌握软件安全测试方法秘笈,安全测试报告信手捏来
sscanf,sscanf_s及其相关使用方法「建议收藏」
MySQL null value processing and value replacement
SQL where multiple field filtering
kivy教程之设置窗体大小和背景(教程含源码)
Golang compresses and decompresses zip files
Win11控制面板快捷键 Win11打开控制面板的多种方法
MySQL split method usage
Easycvr cannot be played using webrtc. How to solve it?
Have you got the same "artifact" of cross architecture development praised by various industry leaders?
How to conduct website testing of software testing? Test strategy let's go!
Lessons and thoughts of the first SQL injection
On the 110th anniversary of Turing's birth, has the prediction of intelligent machine come true?
食堂用户菜品关系系统(C语言课设)
程序员上班摸鱼,这么玩才高端!
广告归因:买量如何做价值衡量?
[ArcGIS tutorial] thematic map production - population density distribution map - population density analysis
软件测试之网站测试如何进行?测试小攻略走起!
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!