LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
sn_set_fork_fanout.m
1%{ @file sn_set_fork_fanout.m
2 % @brief Sets fork fanout (tasksPerLink) for a Fork node
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Sets fork fanout for a Fork node
9 %
10 % @details
11 % Updates the fanOut field in nodeparam for a Fork node.
12 %
13 % @par Syntax:
14 % @code
15 % sn = sn_set_fork_fanout(sn, forkNodeIdx, fanOut)
16 % @endcode
17 %
18 % @par Parameters:
19 % <table>
20 % <tr><th>Name<th>Description
21 % <tr><td>sn<td>Network structure
22 % <tr><td>forkNodeIdx<td>Node index of the Fork node (1-based)
23 % <tr><td>fanOut<td>Number of tasks per output link (>= 1)
24 % </table>
25 %
26 % @par Returns:
27 % <table>
28 % <tr><th>Name<th>Description
29 % <tr><td>sn<td>Modified network structure
30 % </table>
31%}
32function sn = sn_set_fork_fanout(sn, forkNodeIdx, fanOut)
33
34% Verify it's a Fork node
35if sn.nodetype(forkNodeIdx) ~= NodeType.Fork
36 error('sn_set_fork_fanout: Node %d is not a Fork node', forkNodeIdx);
37end
38
39% Update nodeparam
40if ~isfield(sn.nodeparam{forkNodeIdx}, 'fanOut')
41 sn.nodeparam{forkNodeIdx}.fanOut = fanOut;
42else
43 sn.nodeparam{forkNodeIdx}.fanOut = fanOut;
44end
45
46end