How to find First Zagreb Entropy using Matlab code?
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a Graph, and I want to find First Zagreb index and Entropy using Matlab code. Please suggest.
0 Commenti
Risposte (1)
Rushil
il 24 Gen 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 Commenti
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!