-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_circuit_info.m
39 lines (35 loc) · 1.19 KB
/
test_circuit_info.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
% Tests for circuit_info
%% Test: lr_test_two_connected
[G, is_ext_node] = load_mrewiens('lr_test_two_connected');
info = circuit_info(G, is_ext_node);
assert(8 == info.num_nodes)
assert(4 == info.num_external)
assert(4 == info.num_internal)
assert(8 == info.num_resistors)
assert(2 == info.num_conn_components)
%% Test: empty_nodes_no_terminals
G = [1, -1, 0; -1 1 0; 0 0 0];
is_ext_node = [1, 1, 0];
info = circuit_info(G, is_ext_node);
assert(2 == info.num_nodes)
assert(2 == info.num_external)
assert(0 == info.num_internal)
assert(1 == info.num_resistors)
assert(1 == info.num_conn_components)
%% Test: empty_nodes_with_terminal
G = [0, 0, 0, 0; 0, 0, 0, 0; 0, 0, -1, 1; 0, 0, 1, -1];
is_ext_node = [0, 1, 1, 0];
info = circuit_info(G, is_ext_node);
assert(3 == info.num_nodes)
assert(2 == info.num_external)
assert(1 == info.num_internal)
assert(1 == info.num_resistors)
assert(2 == info.num_conn_components)
%% Test: composite
[G, is_ext_node] = load_mrewiens('lr_test_two_connected');
info = circuit_composite_info(G, is_ext_node, G, is_ext_node);
assert(16 == info.num_nodes)
assert(8 == info.num_external)
assert(8 == info.num_internal)
assert(16 == info.num_resistors)
assert(4 == info.num_conn_components)