private int [ ] buildVertexColor ( ) { int [ ] color = new int [ g . length ] ; int n = 1 ; Arrays . fill ( color , - 1 ) ; for ( long cycle : cycles ) { for ( int i = 0 ; i < g . length ; i ++ ) { if ( ( cycle & 0x1 ) == 0x1 ) color [ i ] = color [ i ] < 0 ? n : 0 ; cycle >>= 1 ; } n ++ ; } return color ; }
Build an indexed lookup of vertex color . The vertex color indicates which cycle a given vertex belongs . If a vertex belongs to more then one cycle it is colored 0 . If a vertex belongs to no cycle it is colored - 1 .