create a static call graph from a Maple procedure
Maple procedure, appliable module, string, or set or list of procedures or appliable modules
one or more options as described below
The options argument can contain one or more of the options shown below.
maxdepth=posint or infinity
The maximum depth of procedure calls to examine. The default is infinity, meaning the static call graph is traversed to arbitrary depth.
restrict=r, where r is a symbol or string, or a set or list of symbols or strings
Whether and how to restrict the procedures or appliable modules included as vertices of the resulting graph. If this option is not supplied, then there are no restrictions on which vertices are included. If it is supplied, then a procedure or appliable module p is included only if:
it is listed in r; or
it is a local or export of a module included in r; or
it is a local or export of a module that is, itself, a local or export of a module included in r, and so forth.
This is determined by looking at the name for such procedures or appliable modules that this code finds. Note that if a procedure p1 calls a procedure p2 that is rejected according to this criterion, then that procedure is not examined; if p2 contains any calls to a procedure p3 that would be accepted, then p3 will not be found, at least not through p2.
StaticCallGraph(P) returns a directed graph which represents a static call graph for the input P. The vertices of the graph are strings which represent procedures or appliable modules, and a directed arc exists from f to g when there is an explicit reference to g in the body of f.
If P is a string, then it is interpreted as the name of a Maple library archive, and all procedures defined in it are examined.
The output is a Maple graph suitable for use with commands from the GraphTheory package.
This command generates only simple graphs; recursive calls in a procedure body are not translated into self-loops in the resulting graph.
This command simply examines the procedure body for instances of procedure names. There are many methods of invoking a procedure in Maple (for example, by constructing the procedure's name with cat or parse) which this command makes no effort to detect.
G ≔ StaticCallGraph⁡maximize,maxdepth=2
G≔Graph 1: a directed graph with 22 vertices and 24 arc(s)
The CodeTools[ProgramAnalysis][StaticCallGraph] command was introduced in Maple 2020.
For more information on Maple 2020 changes, see Updates in Maple 2020.
Download Help Document
What kind of issue would you like to report? (Optional)