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

Function is_isolate

easygraph/functions/isolate.py:8–37  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

6
7
8def 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
40def isolates(G):

Callers

nothing calls this directly

Calls 1

degreeMethod · 0.45

Tested by

no test coverage detected