Assume I have the following matrix:

    mat = [1 1 0 0 0 ; 1 1 0 0 0 ; 0 0 0 0 1 ; 0 0 0 1 1]

Considering as a "component" a group of neighbour elements that have value
'1', how to identify that this matrix has 2 components and which vertices
compose each one?

For the matrix *mat* above I would like to find the following result:

Component 1 is composed by the following elements of the matrix
(row,column):

    (1,1)
    (1,2)
    (2,1)
    (2,2)

Component 2 is composed by the following elements:

    (3,5)
    (4,4)
    (4,5)

I can use Graph algorithms like this
<http://graphsjl-docs.readthedocs.org/en/latest/algorithms.html#connected-components>
to identify components in square matrices. However such algorithms can not
be used for non-square matrices like the one I present here.

Any idea will be much appreciated.

I am open if your suggestion involves the use of a Python library + PyCall
for example. Although I would prefer to use a pure Julia solution.

Regards
Charles
P.S.: Just asked the same question in Stackoverflow:
https://stackoverflow.com/questions/32772190/how-to-find-connected-components-in-a-matrix-using-julia

-- 
Um axé! :)

--
Charles Novaes de Santana, PhD
http://www.imedea.uib-csic.es/~charles

Reply via email to