In matlab 2008Error using ==> feval Undefined function or method 'edit6_Callback' for input arguments of type 'struct'.

9 vues (au cours des 30 derniers jours)
function [sequenceOfSPFLinkIds,sequenceOfSPFNodeIds , totalCost] = libraryGraph_capacityShortestPath (linkTable , ingressNode , egressNode , minimumCapacityInEachLink)
numberNetNodes = max (max (linkTable(:,1:2))); numberNetNodes = max ([numberNetNodes ingressNode egressNode]); numberlinkTable = size (linkTable , 1);
intree = zeros (1,numberNetNodes); predLinkIds = -1 * ones (1,numberNetNodes); % the link which takes me to the ingress weightTagsPerNode = inf * ones (1,numberNetNodes); weightTagsPerNode (ingressNode) = 0;
counterOfSteps = 0;
warning ('off' , 'MATLAB:divideByZero');
while (intree (egressNode) ~= 1) && (counterOfSteps <= numberNetNodes) counterOfSteps = counterOfSteps + 1;
for cont=1:length(weightTagsPerNode)
end
% to calculate the node id with lowest tag, only among the ones in the tree
[auxiliar,newNodeIdInTree] = min (weightTagsPerNode ./ (1-intree));
% If the node with lowest tag has an infinite value => nodes not in
% the tree are not connected to the component of the ingress node, and we should stop
if (isinf (weightTagsPerNode(newNodeIdInTree)))
break;
end
intree (newNodeIdInTree) = 1;
outgoingLinksFromNewNodeInTree = find (linkTable(:,1)==newNodeIdInTree);
for outLinkId=outgoingLinksFromNewNodeInTree'
neighbour = linkTable(outLinkId,2);
if (intree (neighbour) == 0)
if (weightTagsPerNode (neighbour) > weightTagsPerNode (newNodeIdInTree) + linkTable (outLinkId,3)) && (linkTable(outLinkId,4) >= minimumCapacityInEachLink)
weightTagsPerNode (neighbour) = weightTagsPerNode (newNodeIdInTree) + linkTable (outLinkId,3);
predLinkIds (neighbour) = outLinkId;
end
end
end
end
% convert the pred structure into a sequence of links sequenceOfLinkIds = []; sequenceOfSPFLinkIds = []; sequenceOfSPFNodeIds = [];
% si el destino no esta en intree es que no habia camino totalCost = 0; if (intree (egressNode) == 1) node = egressNode; sequenceOfSPFNodeIds = [egressNode]; while (node ~= ingressNode) linkToAdd = linkTable (predLinkIds(node),:); totalCost = totalCost + linkToAdd(3); sequenceOfSPFLinkIds = [predLinkIds(node) sequenceOfSPFLinkIds]; node = linkToAdd (1); % source of the link added sequenceOfSPFNodeIds = [node sequenceOfSPFNodeIds]; end end
warning ('on' , 'MATLAB:divideByZero');
  1 commentaire
Rik
Rik le 15 Mar 2017
Have a read here and here. It will greatly improve your chances of getting an answer. Especially the second, since this code is not very readable.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by