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")
| 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. |
no outgoing calls
no test coverage detected