LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
addNode.m
1function isReplacement = addNode(self, node)
2% ADDNODE(NODE)
3
4% Copyright (c) 2012-2026, Imperial College London
5% All rights reserved.
6
7%
8hasSameName = cellfun(@(x) strcmp(x.name,node.name), {self.nodes{1:end}});
9if any(hasSameName)
10 if self.allowReplace
11 oldNode = self.nodes{find(hasSameName)}; %#ok<FNDSB>
12 node.index = oldNode.index;
13 self.nodes{oldNode.index,1} = node;
14 if isa(node,'Station')
15 self.stations{oldNode.stationIndex,1} = node;
16 node.stationIndex = oldNode.stationIndex;
17 end
18 self.setUsedLangFeature(class(node)); % station type
19 self.setUsedLangFeature(class(node.input)); % station type
20 self.setUsedLangFeature(class(node.server)); % station type
21 self.setUsedLangFeature(class(node.output)); % station type
22 isReplacement = true;
23 else
24 line_error(mfilename,'A node with an identical name already exists.');
25 end
26 return;
27end
28self.nodes{end+1,1} = node;
29node.index = length(self.nodes);
30if isa(node,'Station')
31 self.stations{end+1,1} = node;
32 node.stationIndex = length(self.stations);
33end
34self.setUsedLangFeature(class(node)); % station type
35self.setUsedLangFeature(class(node.input)); % station type
36self.setUsedLangFeature(class(node.server)); % station type
37self.setUsedLangFeature(class(node.output)); % station type
38isReplacement = false;
39end