MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
Nodes: [10×1 table]

Get the files required by the timestable.mlapp file.

requiredFiles = bfsearch(g, which('source/timestable.mlapp'))

requiredFiles = 2×1 cell array
{'C:\MATLAB\Projects\examples\TimesTableApp1\source\timestable.mlapp' }
{'C:\MATLAB\Projects\examples\TimesTableApp1\refs\TimesTableGame\timesTableGame.m'}

Get the top-level files of all types in the graph. The indegree function finds all the files
that are not depended on by any other file.

top = g.Nodes.Name(indegree(g)==0)

top = 7×1 cell array
{'C:\MATLAB\Projects\examples\TimesTableApp1\requirements\TimesTableRequirements.mlx'}
{'C:\MATLAB\Projects\examples\TimesTableApp1\tests\tAnswerIsCorrect.m' }
{'C:\MATLAB\Projects\examples\TimesTableApp1\tests\tCurrentQuestion.m' }
{'C:\MATLAB\Projects\examples\TimesTableApp1\tests\tNewTimesTable.m' }
{'C:\MATLAB\Projects\examples\TimesTableApp1\utilities\openRequirementsDocument.m' }
{'C:\MATLAB\Projects\examples\TimesTableApp1\utilities\runTheseTests.m' }
{'C:\MATLAB\Projects\examples\TimesTableApp1\utilities\runTimesTable.m' }

Get the top-level files that have dependencies. The indegree function finds all the files
that are not depended on by any other file, and the outdegree function finds all the files
that have dependencies.

top = g.Nodes.Name(indegree(g)==0 & outdegree(g)>0)

top = 5×1 cell array
{'C:\MATLAB\Projects\examples\TimesTableApp1\requirements\TimesTableRequirements.mlx'}
{'C:\MATLAB\Projects\examples\TimesTableApp1\tests\tAnswerIsCorrect.m' }
{'C:\MATLAB\Projects\examples\TimesTableApp1\tests\tCurrentQuestion.m' }
{'C:\MATLAB\Projects\examples\TimesTableApp1\tests\tNewTimesTable.m' }
{'C:\MATLAB\Projects\examples\TimesTableApp1\utilities\openRequirementsDocument.m' }

Find impacted (or "upstream") files by creating a transposed graph. Use the flipedge
function to reverse the direction of the edges in the graph.

transposed = flipedge(g)

31 Projects

Free download pdf