MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / plot_Followers

Function plot_Followers

easygraph/functions/drawing/plot.py:13–58  ·  view source on GitHub ↗

Returns the CDF curves of "Number of Followers" 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 the CDF curves of "Numb

(G, SHS)

Source from the content-addressed store, hash-verified

11
12# Number of Followers
13def plot_Followers(G, SHS):
14 """
15 Returns the CDF curves of "Number of Followers" of SH spanners and ordinary users in graph G.
16
17 Parameters
18 ----------
19 G : graph
20 A easygraph graph.
21
22 SHS : list
23 The SH Spanners in graph G.
24
25 Returns
26 -------
27 plt : CDF curves
28 the CDF curves of "Number of Followers" of SH spanners and ordinary users in graph G.
29 """
30 import matplotlib.pyplot as plt
31 import numpy as np
32 import statsmodels.api as sm
33
34 OU = []
35 for i in G:
36 if i not in SHS:
37 OU.append(i)
38 degree = G.degree()
39 sample1 = []
40 sample2 = []
41 for i in degree.keys():
42 if i in OU:
43 sample1.append(degree[i])
44 elif i in SHS:
45 sample2.append(degree[i])
46 X1 = np.linspace(min(sample1), max(sample1))
47 ecdf = sm.distributions.ECDF(sample1)
48 Y1 = ecdf(X1)
49 X2 = np.linspace(min(sample2), max(sample2))
50 ecdf = sm.distributions.ECDF(sample2)
51 Y2 = ecdf(X2)
52 plt.plot(X1, Y1, "b--", label="Ordinary User")
53 plt.plot(X2, Y2, "r", label="SH Spanner")
54 plt.title("Number of Followers")
55 plt.xlabel("Number of Followers")
56 plt.ylabel("Cumulative Distribution Function")
57 plt.legend(loc="lower right")
58 plt.show()
59
60
61# Number of Connected Communities

Callers

nothing calls this directly

Calls 2

appendMethod · 0.80
degreeMethod · 0.45

Tested by

no test coverage detected