# how to find the cardinality of neighbors of a set of vertices in a graph by using sagemath?

I am having list of dominating sets of a simple graph G. I need to find the cardinality of neighbors of each dominating sets. For that, first i want to know that how to find cardinality of neighbors of a set of vertices of of G by using sagemath.

Recall the definition of a dominating set. If

`D`

is a dominating set of a graph`G=(V,E)`

, then for each vertex`u\in V`

, either`u`

is in`D`

or it is a neighbor of a vertex in`D`

. I assume that you are interested in the strict neighborhood of`D`

, that is the set of vertices that are neighbors of a vertex in`D`

but are not in`D`

. Obviously, it's`V-D`

and the cardinality of this set is obvious to deduce.