DEVELOPMENT OF GRAPH GENERATION TOOLS FOR PYTHON FUNCTION CODE ANALYSIS

Authors

  • Bayu Samodra Institut Teknologi Bandung
  • Vebby Amelya Nora Institut Teknologi Bandung
  • Fitra Arifiansyah Institut Teknologi Bandung
  • Gusti Ayu Putri Saptawati Soekidjo Institut Teknologi Bandung
  • Muhamad Koyimatu Institut Teknologi Bandung

DOI:

https://doi.org/10.33480/jitk.v10i3.6177

Keywords:

abstract syntax tree, control flow graph, graphviz, python, SDLC

Abstract

The increasing complexity of programs in software development requires understanding and analysis of code structure, especially in Python, which dominates machine learning and data science applications. Manual static analysis is often time-consuming and prone to errors. Meanwhile, static analysis tools for Python, like PyCG and Code2graph, are still limited to generating call graphs without including dependency and control flow analysis. This research addresses these shortcomings by proposing the development of a web-based tool that integrates the generation of function call graphs, function dependency graphs, and control flow graphs using Abstract Syntax Tree (AST), Graphviz, and Streamlit. With an iterative SDLC methodology, this tool was developed gradually to visualize Python function code as a heterogeneous graph. Evaluation of 11 Python function codes showed a success rate of 95.45% in analyzing and visualizing Python function codes with various levels of complexity. The limitations of Graphviz present an opportunity for future research to focus on improving scalability and Python code analysis.

Downloads

Download data is not yet available.

References

M. Alenezi and M. Zarour, “On the Relationship between Software Complexity and Security,” International Journal of Software Engineering & Applications, vol. 11, no. 1, pp. 51–60, Jan. 2020, doi: 10.5121/ijsea.2020.11104.

M. S. Khoirom, M. Sonia, B. Laikhuram, J. Laishram, and D. Singh, “Comparative Analysis of Python and Java for Beginners,” International Research Journal of Engineering and Technology, 2020, Accessed: Dec. 03, 2024. [Online]. Available: https://www.irjet.net/archives/V7/i8/IRJET-V7I8755.pdf

X. Zong, S. Zheng, H. Zou, H. Yu, and S. Gao, “GraphPyRec: A novel graph-based approach for fine-grained Python code recommendation,” Sci Comput Program, vol. 238, Dec. 2024, doi: 10.1016/j.scico.2024.103166.

V. Lenarduzzi, F. Pecorelli, N. Saarimäki, S. Lujan, and F. Palomba, “A Critical Comparison on Six Static Analysis Tools: Detection, Agreement, and Precision,” Journal of Systems and Software, vol. 198, Apr. 2023, doi: 10.1016/j.jss.2022.111575.

H. Bapeer Hassan, Q. Idrees Sarhan, Á. Beszédes, and H. B. Hassan, “Evaluating Python Static Code Analysis Tools Using FAIR Principles,” Nov. 2024, doi: 10.1109/ACCESS.2024.0429000.

G. Antal, P. Hegedus, Z. Herczeg, G. Loki, and R. Ferenc, “Is JavaScript Call Graph Extraction Solved Yet? A Comparative Study of Static and Dynamic Tools,” IEEE Access, vol. 11, pp. 25266–25284, 2023, doi: 10.1109/ACCESS.2023.3255984.

E. Fregnan, J. Fröhlich, D. Spadini, and A. Bacchelli, “Graph-based Visualization of Merge Requests for Code Review,” J Syst Softw, vol. 195, p. 111506, 2023, doi: 10.1016/j.jss.2022.111506.

Y. Jin et al., “Graph-Centric Performance Analysis for Large-Scale Parallel Applications,” IEEE Transactions on Parallel and Distributed Systems, vol. 35, no. 7, pp. 1221–1238, Jul. 2024, doi: 10.1109/TPDS.2024.3396849.

K. Borowski, B. Balis, and T. Orzechowski, “Semantic Code Graph - An Information Model to Facilitate Software Comprehension,” IEEE Access, vol. 12, pp. 27279–27310, 2024, doi: 10.1109/ACCESS.2024.3351845.

O. Rodriguez-Prieto, A. Mycroft, and F. Ortin, “An Efficient and Scalable Platform for Java Source Code Analysis Using Overlaid Graph Representations,” IEEE Access, vol. 8, pp. 72239–72260, 2020, doi: 10.1109/ACCESS.2020.2987631.

Z. Sagodi, E. Pengo, J. Jasz, I. Siket, and R. Ferenc, “Static Call Graph Combination to Simulate Dynamic Call Graph Behavior,” IEEE Access, vol. 10, pp. 131829–131840, 2022, doi: 10.1109/ACCESS.2022.3229182.

R. Alanazi, G. Gharibi, and Y. Lee, “Facilitating Program Comprehension with Call Graph Multilevel Hierarchical Abstractions,” Journal of Systems and Software, vol. 176, Jun. 2021, doi: 10.1016/j.jss.2021.110945.

A. Bansal, Z. Eberhart, Z. Karas, Y. Huang, and C. Mcmillan, “Function Call Graph Context Encoding for Neural Source Code Summarization,” IEEE Transactions on Software Engineering, vol. 49, no. 9, pp. 4268–4281, Sep. 2023, doi: 10.1109/TSE.2023.3279774.

H. Liu, Y. Tao, W. Huang, and H. Lin, “Visual Exploration of Dependency Graph in Source Code Via Embedding-based Similarity,” J Vis (Tokyo), vol. 24, no. 3, pp. 565–581, Jun. 2021, doi: 10.1007/s12650-020-00727-x.

H. V. Tran and P. N. Hung, “A Control Flow Graph Generation Method for Java Projects,” VNU Journal of Science: Computer Science and Communication Engineering, vol. 40, no. 1, Jun. 2024, doi: 10.25073/2588-1086/vnucsce.668.

P. Bedadala, M. D, and L. S. Nair, “Generation of Call Graph for Java Higher Order Functions,” in Proceedings of the Fifth International Conference on Communication and Electronics Systems (ICCES), IEEE, 2020. Accessed: Nov. 20, 2024. [Online]. Available: https://ieeexplore.ieee.org/document/9138056

P. Jansen, “TIOBE Index for November 2024,” https://www.tiobe.com/tiobe-index/.

Z. Zhao, X. Wang, Z. Xu, Z. Tang, Y. Li, and P. Di, “Incremental Call Graph Construction in Industrial Practice,” in Proceedings - International Conference on Software Engineering, IEEE Computer Society, 2023, pp. 471–482. doi: 10.1109/ICSE-SEIP58684.2023.00048.

V. Salis, T. Sotiropoulos, P. Louridas, D. Spinellis, and D. Mitropoulos, “PyCG: Practical Call Graph Generation in Python,” in Proceedings - International Conference on Software Engineering, IEEE Computer Society, May 2021, pp. 1646–1657. doi: 10.1109/ICSE43902.2021.00146.

N. Mehrotra, A. Sharma, A. Jindal, and R. Purandare, “Improving Cross-Language Code Clone Detection via Code Representation Learning and Graph Neural Networks,” IEEE Transactions on Software Engineering, vol. 49, no. 11, pp. 4846–4868, Nov. 2023, doi: 10.1109/TSE.2023.3311796.

Q. Yas, B. Rahmatullah, A. Alazzawi, and Q. M. Yas, “A Comprehensive Review of Software Development Life Cycle methodologies: Pros, Cons, and Future Directions,” Iraqi Journal for Computer Science and Mathematics, vol. Vol. 4 No. 4, pp. 173–0, 2023, doi: 10.52866/ijcsm.2023.04.04.0.

Y. Huang, M. He, X. Wang, and J. Zhang, “HeVulD: A Static Vulnerability Detection Method using Heterogeneous Graph Code Representation,” IEEE Transactions on Information Forensics and Security, 2024, doi: 10.1109/TIFS.2024.3457162.

H. Il Lim, “An approach to comparing control flow graphs based on basic block matching,” Indian Journal of Computer Science and Engineering, vol. 11, no. 3, pp. 289–296, May 2020, doi: 10.21817/indjcse/2020/v11i3/201103237.

Downloads

Published

2025-02-21

How to Cite

[1]
B. Samodra, V. A. Nora, F. Arifiansyah, G. A. Putri Saptawati Soekidjo, and M. Koyimatu, “DEVELOPMENT OF GRAPH GENERATION TOOLS FOR PYTHON FUNCTION CODE ANALYSIS”, jitk, vol. 10, no. 3, pp. 690–697, Feb. 2025.