%% Visualize Sounds Supported by YAMNet
% Create a digraph object that describes the AudioSet ontology. Also return the classes supported by YAMNet. Plot the directed graph.

[ygraph,classes] = yamnetGraph;
p = plot(ygraph);
layout(p,'layered')

%
% YAMNet predicts a subset of the full AudioSet ontology. Display the sound classes that are in the AudioSet ontology but are not possible outputs from the YAMNet network.

audiosetClasses = ygraph.Nodes.Name;
classDiff = setdiff(audiosetClasses,classes)

%
% Highlight the classes that are not possible outputs from YAMNet.

highlight(p,classDiff,'NodeColor','r')

%
% Analyze one of the major categories.

categoryToAnalyze = "Channel, environment and background";
subsetNodes = dfsearch(ygraph,categoryToAnalyze);
ygraphSubset = subgraph(ygraph,subsetNodes);
classToHighlight = intersect(classDiff,ygraphSubset.Nodes.Name);
pSub = plot(ygraphSubset);
layout(pSub,'layered')
highlight(pSub,classToHighlight,'NodeColor','r')

% Copyright 2020 The MathWorks, Inc.