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

Method out_degree

easygraph/classes/directed_graph.py:130–170  ·  view source on GitHub ↗

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

(self, weight="weight")

Source from the content-addressed store, hash-verified

128 self.graph["name"] = s
129
130 def out_degree(self, weight="weight"):
131 """Returns the weighted out degree of each node.
132
133 Parameters
134 ----------
135 weight : string, optional (default : 'weight')
136 Weight key of the original weighted graph.
137
138 Returns
139 -------
140 out_degree : dict
141 Each node's (key) weighted out degree (value).
142
143 Notes
144 -----
145 If the graph is not weighted, all the weights will be regarded as 1.
146
147 See Also
148 --------
149 in_degree
150 degree
151
152 Examples
153 --------
154
155 >>> G.out_degree(weight='weight')
156
157 """
158 degree = dict()
159 for u, v, d in self.edges:
160 if u in degree:
161 degree[u] += d.get(weight, 1)
162 else:
163 degree[u] = d.get(weight, 1)
164
165 # For isolated nodes
166 for node in self.nodes:
167 if node not in degree:
168 degree[node] = 0
169
170 return degree
171
172 def in_degree(self, weight="weight"):
173 """Returns the weighted in degree of each node.

Callers 5

degreeMethod · 0.95
sizeMethod · 0.95
out_degree_centralityFunction · 0.45
modularityFunction · 0.45
_find_separation_nodesFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected