-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcircuit_info.m
More file actions
25 lines (20 loc) · 772 Bytes
/
Copy pathcircuit_info.m
File metadata and controls
25 lines (20 loc) · 772 Bytes
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
function [ info ] = circuit_info( G, is_ext_node )
%CIRCUIT_INFO Computes stats for circuit descibed by G and is_ext_node.
assert(size(G,1) == size(G,2))
assert(size(G,1) == length(is_ext_node))
non_empty_nodes = any(G,2);
empty_nodes = ~any(G,2);
s = sum(is_ext_node(empty_nodes)); % account for not connected ext nodes
info = struct;
info.num_nodes = length(G(non_empty_nodes, non_empty_nodes)) + s;
info.num_external = length(find(is_ext_node == 1));
info.num_internal = info.num_nodes - info.num_external;
info.num_resistors = count_resistors(G);
c = components(adj(G(non_empty_nodes, non_empty_nodes)));
if isempty(c)
info.num_conn_components = 0;
else
info.num_conn_components = max(c);
end
info.num_conn_components = info.num_conn_components + s;
end