-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathllist.m
72 lines (60 loc) · 2.14 KB
/
llist.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
classdef llist < handle
%LLIST Implementation of a dependency graph vertice.
% This class represents both a vertice used in a graph, as well as
% the edges between them. A vertice has both in-/ and outgoing edges,
% Vertices are linked together by two properties representing the
% in-/ and outgoing edges.
properties(SetAccess = public)
% Unique identifier
id;
% Data of this vertice
Data;
% Ingoing edges
In = {};
% Outgoing edges
Out = {};
end
methods
function node = llist(Data, id)
%LLIST Construct a llist object.
% Set the Data and id of the entitie.
if nargin > 0
node.Data = Data;
node.id = id;
end
end
function insert(node, newNode, in, out)
%INSERT Create dependency between two entities.
% Create a outgoing dependency from node to newNode.
node.Out{end + 1} = {out, newNode};
newNode.In{end + 1} = {in, node};
end
function gOut = get_out_all(node)
%GET_OUT_ALL Get all output parts
% Return all parts to which this entity has outgoing
% dependencies to.
gOut = {};
for j = 1:size(node.Out, 2)
if size(node.Out{j}, 2) == 2
gOut{end + 1} = node.Out{j}{2};
end
end
end
function wave = get_in_min(node)
%GET_IN_MIN Get the smallest input waveguide.
% Return the input waveguide with the lowest number.
wave = -1;
for j = 1:size(node.In, 2)
if size(node.In{j}, 2) == 2
if wave == -1
wave = node.In{j}{1};
else
if wave > node.In{j}{1}
wave = node.In{j}{1};
end
end
end
end
end
end
end