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

Method in_degree

easygraph/classes/directed_graph.py:172–212  ·  view source on GitHub ↗

Returns the weighted in degree of each node. Parameters ---------- weight : string, optional (default : 'weight') Weight key of the original weighted graph. Returns ------- in_degree : dict Each node's (key) weighted in degree

(self, weight="weight")

Source from the content-addressed store, hash-verified

170 return degree
171
172 def in_degree(self, weight="weight"):
173 """Returns the weighted in degree of each node.
174
175 Parameters
176 ----------
177 weight : string, optional (default : 'weight')
178 Weight key of the original weighted graph.
179
180 Returns
181 -------
182 in_degree : dict
183 Each node's (key) weighted in degree (value).
184
185 Notes
186 -----
187 If the graph is not weighted, all the weights will be regarded as 1.
188
189 See Also
190 --------
191 out_degree
192 degree
193
194 Examples
195 --------
196
197 >>> G.in_degree(weight='weight')
198
199 """
200 degree = dict()
201 for u, v, d in self.edges:
202 if v in degree:
203 degree[v] += d.get(weight, 1)
204 else:
205 degree[v] = d.get(weight, 1)
206
207 # For isolated nodes
208 for node in self.nodes:
209 if node not in degree:
210 degree[node] = 0
211
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.

Callers 7

degreeMethod · 0.95
topological_generationsFunction · 0.45
in_degree_centralityFunction · 0.45
modularityFunction · 0.45
_linear_thresholdFunction · 0.45
_find_separation_nodesFunction · 0.45
_linear_thresholdFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected