1% Finds all the paths coming out of start, computes the total response time along them, and identifies all the stations along these paths
2function [ri, stat, RN] = pathsCS(sn, orignodes,
P, curNode, endNode, curClass, RN, currentTime, stats)
11 if ~isnan(sn.nodeToStation(curNode))
12 currentRn = RN(sn.nodeToStation(curNode), curClass);
13 stats(end + 1) = sn.nodeToStation(curNode);
15 for transition=find(
P((curClass-1)*orignodes+curNode, :))
16 nextClass = floor((transition - 1) / orignodes) + 1;
17 nextNode = transition-(nextClass-1) * orignodes; %
new class
18 if sn.nodetype(nextNode) == NodeType.Fork & ~isempty(find(sn.fj(nextNode,:)))
19 % Encountered nested fork, compute the max along the parallel paths
20 joinIdx = find(sn.fj(nextNode,:));
21 if RN(sn.nodeToStation(joinIdx), nextClass) == 0
22 [ri1, stat1, RN] = pathsCS(sn,
P, nextNode, joinIdx, nextClass, RN, 0, []);
25 parallel_branches = length(ri1);
26 for pow=0:(parallel_branches - 1)
27 current_sum = sum(1./sum(nchoosek(lambdai, pow + 1),2));
28 d0 = d0 + (-1)^pow * current_sum;
30 RN(sn.nodeToStation(joinIdx), nextClass) = d0;
31 RN(stat1, nextClass) = 0;
33 [ri1, stat1, RN] = pathsCS(sn, orignodes,
P, joinIdx, endNode, nextClass, RN, currentTime + currentRn, stats);
35 [ri1, stat1, RN] = pathsCS(sn, orignodes,
P, nextNode, endNode, nextClass, RN, currentTime + currentRn, stats);