Determines whether a node is an isolate. An *isolate* is a node with no neighbors (that is, with degree zero). For directed graphs, this means no in-neighbors and no out-neighbors. Parameters ---------- G : EasyGraph graph n : node A node in `G`. Returns
(G, n)
| 6 | |
| 7 | |
| 8 | def is_isolate(G, n): |
| 9 | """Determines whether a node is an isolate. |
| 10 | |
| 11 | An *isolate* is a node with no neighbors (that is, with degree |
| 12 | zero). For directed graphs, this means no in-neighbors and no |
| 13 | out-neighbors. |
| 14 | |
| 15 | Parameters |
| 16 | ---------- |
| 17 | G : EasyGraph graph |
| 18 | |
| 19 | n : node |
| 20 | A node in `G`. |
| 21 | |
| 22 | Returns |
| 23 | ------- |
| 24 | is_isolate : bool |
| 25 | True if and only if `n` has no neighbors. |
| 26 | |
| 27 | Examples |
| 28 | -------- |
| 29 | >>> G = eg.Graph() |
| 30 | >>> G.add_edge(1, 2) |
| 31 | >>> G.add_node(3) |
| 32 | >>> eg.is_isolate(G, 2) |
| 33 | False |
| 34 | >>> eg.is_isolate(G, 3) |
| 35 | True |
| 36 | """ |
| 37 | return G.degree()[n] == 0 |
| 38 | |
| 39 | |
| 40 | def isolates(G): |