How to find First Zagreb Entropy using Matlab code?
3 ビュー (過去 30 日間)
古いコメントを表示
I have a Graph, and I want to find First Zagreb index and Entropy using Matlab code. Please suggest.
0 件のコメント
回答 (1 件)
Rushil
2025 年 1 月 24 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!