From: El O. De M. <obs...@gm...> - 2023-11-15 16:15:17
|
Hi Here is a function that returns a graph associated with the current functions in a session (functions recognized by *functions*, not lisp functions). The function generates a graph that later can be used with the command draw_graph or print_graph. I do not know much about graph theory or computer science, but i wonder if some graph property is desirable for a package. More work can be done to improve the function (the graph includes the function itself), and some packages do not return, in the wxMaxima session, the plot in the same page (it is opened in an emerging window). Also, for some large packages is necessary to drop interactively the plot to take a closer look or zoom; packages must be "scanned" separately. Some results: (%i1) load("absimp.mac"); (%o1) "C:\maxima-5.46.0\share\maxima\5.46.0\share\simplification\absimp.mac" (%i2) package_graph():=block( A:map(op,functions), len:length(A), B:map(lambda([x],rhs(apply(fundef,[x]))),A), C:makelist([i,A[i]],i,len), D:unique(map(sort,delete(false,map(lambda([x],if x[1]#x[2] and ssearch(string(A[x[1]]),string(B[x[2]]))#false then x),create_list([i,j],i,1,len,j,1,len))))), load(graphs), create_graph(C,D) )$ (%i3) package_graph(); (%o3) GRAPH\(8 vertices, 5 edges\) (%i1) file_search(nusum)$ (%i2) load(%)$ (%i3) package_graph():=block( A:map(op,functions), len:length(A), B:map(lambda([x],rhs(apply(fundef,[x]))),A), C:makelist([i,A[i]],i,len), D:unique(map(sort,delete(false,map(lambda([x],if x[1]#x[2] and ssearch(string(A[x[1]]),string(B[x[2]]))#false then x),create_list([i,j],i,1,len,j,1,len))))), load(graphs), create_graph(C,D) )$ (%i4) package_graph(); (%o4) GRAPH\(18 vertices, 19 edges\) (%i1) showtime:true$ Evaluation took 0.0000 seconds (0.0000 elapsed) using 32 bytes. (%i2) file_search(sarag)$ Evaluation took 0.2969 seconds (0.2969 elapsed) using 1.801 MB. (%i3) load(%)$ Evaluation took 1.2187 seconds (1.2343 elapsed) using 28.744 MB. (%i4) package_graph():=block( A:map(op,functions), len:length(A), B:map(lambda([x],rhs(apply(fundef,[x]))),A), C:makelist([i,A[i]],i,len), D:unique(map(sort,delete(false,map(lambda([x],if x[1]#x[2] and ssearch(string(A[x[1]]),string(B[x[2]]))#false then x),create_list([i,j],i,1,len,j,1,len))))), load(graphs), create_graph(C,D) )$ Evaluation took 0.0000 seconds (0.0000 elapsed) using 208 bytes. (%i5) package_graph(); Evaluation took 104.1250 seconds (104.2445 elapsed) using 9173.345 MB. (%o5) GRAPH\(435 vertices, 824 edges\) To see the plot use draw_graph and the option show_label=true (draw_graph(%,show_label=true)) best regards. -- https://github.com/Observatorio-de-Matematica |