Java program:
import java . io . * ; import java . util . * ; class GFG { static void depthFirst ( int v , List < List < Integer > > graph , boolean [ ] visited , List < Integer > storeChain ) { visited [ v ] = true ; storeChain . add ( v ) ; for ( int i : graph . get ( v ) ) { if ( visited [ i ] == false ) { depthFirst ( i , graph , visited , storeChain ) ; } } } static void createMap ( Map < String , Character > um ) { um . put ( "0000" , '0' ) ; um . put ( "0001" , '1' ) ; um . put ( "0010" , '2' ) ; um . put ( "0011" , '3' ) ; um . put ( "0100" , '4' ) ; um . put ( "0101" , '5' ) ; um . put ( "0110" , '6' ) ; um . put ( "0111" , '7' ) ; um . put ( "1000" , '8' ) ; um . put ( "1001" , '9' ) ; um . put ( "1010" , ' A ' ) ; um . put ( "1011" , ' B ' ) ; um . put ( "1100" , ' C ' ) ; um . put ( "1101" , ' D ' ) ; um . put ( "1110" , ' E ' ) ; um . put ( "1111" , ' F ' ) ; } static String hexaDecimal ( String bin ) { int l = bin . length ( ) ; int t = bin . indexOf ( ' . ' ) ; int len_left = t != - 1 ? t : l ; for ( int i = 1 ; i <= ( 4 - len_left % 4 ) % 4 ; i ++ ) bin = '0' + bin ; if ( t != - 1 ) { int len_right = l - len_left - 1 ; for ( int i = 1 ; i <= ( 4 - len_right % 4 ) % 4 ; i ++ ) bin = bin + '0' ; } Map < String , Character > bin_hex_map = new HashMap < String , Character > ( ) ; createMap ( bin_hex_map ) ; int i = 0 ; String hex = " " ; while ( true ) { hex += bin_hex_map . get ( bin . substring ( i , i + 4 ) ) ; i += 4 ; if ( i == bin . length ( ) ) break ; if ( bin . charAt ( i ) == ' . ' ) { hex += ' . ' ; i ++ ; } } return hex ; } static void hexValue ( List < List < Integer > > graph , int vertices , List < Integer > values ) { boolean [ ] visited = new boolean [ 1001 ] ; for ( int i = 1 ; i <= vertices ; i ++ ) { if ( visited [ i ] == false ) { int sizeChain ; List < Integer > storeChain = new ArrayList < Integer > ( ) ; depthFirst ( i , graph , visited , storeChain ) ; sizeChain = storeChain . size ( ) ; int [ ] chainValues = new int [ sizeChain + 1 ] ; for ( int j = 0 ; j < sizeChain ; j ++ ) { int temp = values . get ( storeChain . get ( j ) - 1 ) ; chainValues [ j ] = temp ; } System . out . print ( " Chain ▁ = ▁ " ) ; for ( int j = 0 ; j < sizeChain ; j ++ ) { System . out . print ( chainValues [ j ] + " ▁ " ) ; } System . out . println ( ) ; System . out . print ( " TABSYMBOL " ) ; String s = " " ; for ( int j = 0 ; j < sizeChain ; j ++ ) { String s1 = String . valueOf ( chainValues [ j ] ) ; s += s1 ; } System . out . println ( " Hexadecimal ▁ " + " equivalent ▁ = ▁ " + hexaDecimal ( s ) ) ; } } } public static void main ( String [ ] args ) { @ SuppressWarnings ( " unchecked " ) List < List < Integer > > graph = new ArrayList ( ) ; for ( int i = 0 ; i < 1001 ; i ++ ) graph . add ( new ArrayList < Integer > ( ) ) ; int E = 4 , V = 7 ; List < Integer > values = new ArrayList < Integer > ( ) ; values . add ( 0 ) ; values . add ( 1 ) ; values . add ( 1 ) ; values . add ( 1 ) ; values . add ( 0 ) ; values . add ( 1 ) ; values . add ( 1 ) ; graph . get ( 1 ) . add ( 2 ) ; graph . get ( 2 ) . add ( 1 ) ; graph . get ( 3 ) . add ( 4 ) ; graph . get ( 4 ) . add ( 3 ) ; graph . get ( 4 ) . add ( 5 ) ; graph . get ( 5 ) . add ( 4 ) ; graph . get ( 6 ) . add ( 5 ) ; graph . get ( 5 ) . add ( 6 ) ; graph . get ( 6 ) . add ( 7 ) ; graph . get ( 7 ) . add ( 6 ) ; hexValue ( graph , V , values ) ; } }

Index/key variables: i, j, v
Accumulator variables: hex, i, j, s
Iterator variables: i, j
Class/struct names: GFG