added abstract network graph plot

This commit is contained in:
2025-10-27 19:52:10 -07:00
parent b2787e1e53
commit f953cd3882
3 changed files with 29 additions and 1 deletions

22
miSim.m
View File

@@ -59,7 +59,7 @@ classdef miSim
end
end
obj.adjacency = A;
obj.adjacency = A | A';
end
function f = plotNetwork(obj, f)
arguments (Input)
@@ -97,6 +97,26 @@ classdef miSim
copyobj(o, f.Children(1).Children(5));
end
end
function f = plotGraph(obj, f)
arguments (Input)
obj (1, 1) {mustBeA(obj, 'miSim')};
f (1, 1) {mustBeA(f, 'matlab.ui.Figure')} = figure;
end
arguments (Output)
f (1, 1) {mustBeA(f, 'matlab.ui.Figure')};
end
% Form graph from adjacency matrix
G = graph(obj.adjacency, 'omitselfloops');
% Check if this is a tiled layout figure
if strcmp(f.Children(1).Type, 'tiledlayout')
o = plot(f.Children(1).Children(4), G, 'LineStyle', '--', 'EdgeColor', 'g', 'NodeColor', 'k');
else
o = plot(f.CurrentAxes, G, 'LineStyle', '--', 'EdgeColor', 'g', 'NodeColor', 'k');
end
end
end
methods (Access = private)