How to find First Zagreb Entropy using Matlab code?
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a Graph, and I want to find First Zagreb index and Entropy using Matlab code. Please suggest.
0 comentarios
Respuestas (1)
Rushil
el 24 de En. de 2025
Hi Imran
From the question, I assume that there is a MATLAB “graph” object in use. A typical graph object is used as follows:
s = [1 1 2 3]; % source nodes
t = [2 3 3 4]; % target nodes
G = graph(s, t);
You can read more about the "graph" object here:
Now, the first zagreb index can be computed by summing over the squares of degrees of all nodes. Also, a common way to calculate entropy is using Shannon entropy using the degrees of the nodes. Below is the implementation of the same:
degrees = degree(G);
firstZagrebIndex = sum(degrees.^2);
degreeCounts = histcounts(degrees, 'Normalization', 'probability');
entropy = -sum(degreeCounts .* log2(degreeCounts + eps)); % eps is used to avoid log(0)
To read more about Shannon entropy you can visit and scroll down on this page to "More About":
Hope it helps
0 comentarios
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!