File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed
Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -2569,6 +2569,35 @@ def relative_codelength_savings(self):
25692569 """
25702570 return super ().getRelativeCodelengthSavings ()
25712571
2572+ @property
2573+ def entropy_rate (self ):
2574+ """Get the entropy rate of the network.
2575+
2576+ The entropy rate is an indication of the sparsity of a network.
2577+ A higher entropy rate corresponds to a densely connected network.
2578+
2579+ Notes
2580+ -----
2581+ This value is only accessable after running the optimizer (``im.run()``).
2582+
2583+ Examples
2584+ --------
2585+
2586+ >>> from infomap import Infomap
2587+ >>> im = Infomap(silent=True, no_infomap=True)
2588+ >>> im.read_file("twotriangles.net")
2589+ >>> im.run()
2590+ >>> f"{im.entropy_rate:.5f}"
2591+ '0.35714'
2592+
2593+
2594+ Returns
2595+ -------
2596+ float
2597+ The entropy rate
2598+ """
2599+ return super ().getEntropyRate ()
2600+
25722601 @property
25732602 def meta_codelength (self ):
25742603 """Get the meta codelength.
Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ struct InfomapWrapper : public InfomapBase {
9191 }
9292
9393 using InfomapBase::codelength;
94+ using InfomapBase::getEntropyRate;
9495 using InfomapBase::getMultilevelModules;
9596 using InfomapBase::iterLeafNodes;
9697 using InfomapBase::iterTree;
Original file line number Diff line number Diff line change @@ -135,6 +135,8 @@ class InfomapBase : public InfomapConfig<InfomapBase> {
135135 return oneLevelCodelength < 1e-16 ? 0 : 1.0 - codelength () / oneLevelCodelength;
136136 }
137137
138+ double getEntropyRate () { return calcEntropyRate (); }
139+
138140 const Date& getStartDate () const { return m_startDate; }
139141 const Stopwatch& getElapsedTime () const { return m_elapsedTime; }
140142
You can’t perform that action at this time.
0 commit comments