Draws the node as a circle with the given radius, fill, stroke and strokewidth. Draws the node centrality as a shadow effect when weighted=True. Draws the node text label. Override this method in a subclass for custom drawing.
(self, weighted=False)
| 160 | return [n for n,d in _visited.values()] # Fast, but not order-preserving. |
| 161 | |
| 162 | def draw(self, weighted=False): |
| 163 | """ Draws the node as a circle with the given radius, fill, stroke and strokewidth. |
| 164 | Draws the node centrality as a shadow effect when weighted=True. |
| 165 | Draws the node text label. |
| 166 | Override this method in a subclass for custom drawing. |
| 167 | """ |
| 168 | # Draw the node weight as a shadow (based on node betweenness centrality). |
| 169 | if weighted is not False and self.centrality > (weighted==True and -1 or weighted): |
| 170 | w = self.centrality * 35 |
| 171 | ellipse( |
| 172 | self.x, |
| 173 | self.y, |
| 174 | self.radius*2 + w, |
| 175 | self.radius*2 + w, fill=(0,0,0,0.2), stroke=None) |
| 176 | # Draw the node. |
| 177 | ellipse( |
| 178 | self.x, |
| 179 | self.y, |
| 180 | self.radius*2, |
| 181 | self.radius*2, fill=self.fill, stroke=self.stroke, strokewidth=self.strokewidth) |
| 182 | # Draw the node text label. |
| 183 | if self.text: |
| 184 | self.text.draw( |
| 185 | self.x + self.radius, |
| 186 | self.y + self.radius) |
| 187 | |
| 188 | def contains(self, x, y): |
| 189 | """ Returns True if the given coordinates (x, y) are inside the node radius. |