Suppose there are n
distinct points P1, P2,...,Pn
.
Define the connectedness matrix M=(c_ij)
to be a square matrix of the size n
.c_ij
will give true
if i=j
or there is a line segment between point Pi
and Pj
.
A set of points are connected if between any two points there is at least one path(set of line segments). We call the connected set of point a proper graph. A point itself can be a proper graph.
Two proper graphs are disconnected when there is no connection from any point in the first graph to any point in the second graph.
Connectedness is defined as number of disconnected proper graphs.
For example,
P1 P2 P3 P4 P5
P1 true false true false false
P2 false true false false false
P3 true false true false true
P4 false false false true true
P5 false false true true true
has two disconnected proper graphs, i.e. P2
and {P1,P3,P4,P5}
.
My problem is how to write a function to takes in the connectedness matrix and return a list of disconnected proper graphs. For example, the above example should return list(list(1,3,4,5),list(2))
.