Malaysian Journal of Mathematical Sciences, December 2025, Vol. 19, No. 4


Computation of Distance-Based Polynomials and Topological Indices for Generalized Friendship Graphs $(\mathscr{G}(n,k))$: A Python-Based Approach

Altassan, A. and Ahmad, H.

Corresponding Email: haseeb.ahmad@leads.edu.pk

Received date: 11 March 2025
Accepted date: 13 June 2025

Abstract:
In this research, we present a Python-based algorithm for efficiently computing distance-based topological indices and polynomials for the generalized friendship graph $\mathscr{G}(n,k)$. We calculate both Hosoya polynomial and Harary polynomial and establish indices which include the Wiener index, hyper-Wiener index, Harary index, and multiplicative Wiener index. The paper discusses new index modifications which include modified Wiener index combined with modified hyper-Wiener index and modified Harary index and their subsequent analysis. The proposed Python algorithm uses the Floyd-Warshall method to efficiently compute distances between graph nodes, enabling the rapid determination of all relevant indices and associated polynomials. This paper presents visualization graphs to demonstrate the changes observed in the indices as graph parameters vary. We use computational methods to develop knowledge about graph polynomials and indices resulting in practical application possibilities for modeling social networks and theoretical graph examination.

Keywords: distance; generalized friendship graph; Hosoya polynomial; Harary polynomial; Wiener index; hyper Wiener index; Harary index; multiplicative Wiener index; Python algorithm