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 graphG=(V,E)
, then for each vertexu\in V
, eitheru
is inD
or it is a neighbor of a vertex inD
. I assume that you are interested in the strict neighborhood ofD
, that is the set of vertices that are neighbors of a vertex inD
but are not inD
. Obviously, it'sV-D
and the cardinality of this set is obvious to deduce.