Returns the CDF curves of "Arg. Number of Followers of the Neighborhood Users" of SH spanners and ordinary users in graph G. Parameters ---------- G : graph A easygraph graph. SHS : list The SH Spanners in graph G. Returns ------- plt : CDF curves
(G, SHS)
| 172 | |
| 173 | # Arg. Number of Followers of the Neighborhood Users |
| 174 | def plot_Neighborhood_Followers(G, SHS): |
| 175 | """ |
| 176 | Returns the CDF curves of "Arg. Number of Followers of the Neighborhood Users" of SH spanners and ordinary users in graph G. |
| 177 | |
| 178 | Parameters |
| 179 | ---------- |
| 180 | G : graph |
| 181 | A easygraph graph. |
| 182 | |
| 183 | SHS : list |
| 184 | The SH Spanners in graph G. |
| 185 | |
| 186 | Returns |
| 187 | ------- |
| 188 | plt : CDF curves |
| 189 | the CDF curves of "Arg. Number of Followers of the Neighborhood Users |
| 190 | " of SH spanners and ordinary users in graph G. |
| 191 | """ |
| 192 | import matplotlib.pyplot as plt |
| 193 | import numpy as np |
| 194 | import statsmodels.api as sm |
| 195 | |
| 196 | OU = [] |
| 197 | for i in G: |
| 198 | if i not in SHS: |
| 199 | OU.append(i) |
| 200 | sample1 = [] |
| 201 | sample2 = [] |
| 202 | degree = G.degree() |
| 203 | for i in OU: |
| 204 | num = 0 |
| 205 | sum = 0 |
| 206 | for neighbor in G.neighbors(node=i): |
| 207 | num = num + 1 |
| 208 | sum = sum + degree[neighbor] |
| 209 | sample1.append(sum / num) |
| 210 | for i in SHS: |
| 211 | num = 0 |
| 212 | sum = 0 |
| 213 | for neighbor in G.neighbors(node=i): |
| 214 | num = num + 1 |
| 215 | sum = sum + degree[neighbor] |
| 216 | sample2.append(sum / num) |
| 217 | X1 = np.linspace(min(sample1), max(sample1)) |
| 218 | ecdf = sm.distributions.ECDF(sample1) |
| 219 | Y1 = ecdf(X1) |
| 220 | X2 = np.linspace(min(sample2), max(sample2)) |
| 221 | ecdf = sm.distributions.ECDF(sample2) |
| 222 | Y2 = ecdf(X2) |
| 223 | plt.plot(X1, Y1, "b--", label="Ordinary User") |
| 224 | plt.plot(X2, Y2, "r", label="SH Spanner") |
| 225 | plt.title("Arg. Number of Followers of the Neighborhood Users") |
| 226 | plt.xlabel("Arg. Number of Followers of the Neighborhood Users") |
| 227 | plt.ylabel("Cumulative Distribution Function") |
| 228 | plt.legend(loc="lower right") |
| 229 | plt.show() |