static int countPaths ( Vector < Integer > [ ] adj , int k , int maxn ) {
  boolean [ ] vis = new boolean [ maxn + 1 ] ;
  int ans = 0 ;
  Arrays . fill ( vis , false ) ;
  for ( int i = 1 ;
  i <= maxn ;
  i ++ ) {
    if ( ! vis [ i ] ) {
      int numNodes = dfs ( i , 0 , adj , vis ) ;
      ans += numNodes * ( numNodes - 1 ) / 2 ;
    }
  }
  return ans ;
}

static int countPaths ( Vector < Integer > [ ] adj , int k , int maxn ) { boolean [ ] vis = new boolean [ maxn + 1 ] ; int ans = 0 ; Arrays . fill ( vis , false ) ; for ( int i = 1 ; i <= maxn ; i ++ ) { if ( ! vis [ i ] ) { int numNodes = dfs ( i , 0 , adj , vis ) ; ans += numNodes * ( numNodes - 1 ) / 2 ; } } return ans ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (generic_type (type_identifier) (type_arguments (type_identifier))) dimensions: (dimensions)) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (array_type element: (boolean_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (boolean_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (false)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (unary_expression operand: (array_access array: (identifier) index: (identifier)))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal) (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (decimal_integer_literal)))))))) (return_statement (identifier))))