create graph with n * n node each cell consider as node Number of current vertex
k = 1 NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT if ( M [ i ] [ j ] != 0 ) : NEW_LINE DEDENT DEDENT