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

Method degree

easygraph/classes/directed_graph.py:214–253  ·  view source on GitHub ↗

Returns the weighted degree of each node, i.e. sum of out/in degree. Parameters ---------- weight : string, optional (default : 'weight') Weight key of the original weighted graph. Returns ------- degree : dict Each node's (ke

(self, weight="weight")

Source from the content-addressed store, hash-verified

212 return degree
213
214 def degree(self, weight="weight"):
215 """Returns the weighted degree of each node, i.e. sum of out/in degree.
216
217 Parameters
218 ----------
219 weight : string, optional (default : 'weight')
220 Weight key of the original weighted graph.
221
222 Returns
223 -------
224 degree : dict
225 Each node's (key) weighted in degree (value).
226 For directed graph, it returns the sum of out degree and in degree.
227
228 Notes
229 -----
230 If the graph is not weighted, all the weights will be regarded as 1.
231
232 See also
233 --------
234 out_degree
235 in_degree
236
237 Examples
238 --------
239
240 >>> G.degree()
241 >>> G.degree(weight='weight')
242
243 or you can customize the weight key
244
245 >>> G.degree(weight='weight_1')
246
247 """
248 degree = dict()
249 outdegree = self.out_degree(weight=weight)
250 indegree = self.in_degree(weight=weight)
251 for u in outdegree:
252 degree[u] = outdegree[u] + indegree[u]
253 return degree
254
255 def size(self, weight=None):
256 """Returns the number of edges or total of all edge weights.

Callers 1

TransitionFunction · 0.95

Calls 2

out_degreeMethod · 0.95
in_degreeMethod · 0.95

Tested by

no test coverage detected