%% Visualize Specificity of Sound Classes
% Create a digraph object that describes the AudioSet ontology.

ygraph = yamnetGraph;

%
% Specify a sound class to visualize, and specify the number of predecessors and successors. The available sound classes are only those that are supported as outputs from YAMNet. If you specify more predecessors or successors than those in the ontology, only the predecessors and successors in the ontology are shown.

soundClass = "Growling";
numPredecessors = 3;
numSuccessors = 0;

pred = nearest(ygraph,soundClass,numPredecessors,'Direction','incoming');
suc = nearest(ygraph,soundClass,numSuccessors,'Direction','outgoing');
subClasses = [soundClass;pred;suc];

ygraphSub = subgraph(ygraph,unique(subClasses));
p = plot(ygraphSub);
layout(p,'layered')
highlight(p,soundClass,'Marker','d','NodeColor','red','MarkerSize',6)

% Copyright 2020 The MathWorks, Inc.