static boolean bellmanFord ( ) {
  for ( int i = 0 ;
  i < MAX ;
  i ++ ) {
    d [ i ] = INF ;
  }
  d [ 0 ] = 0 ;
  for ( int i = 0 ;
  i < 2 * N ;
  i ++ ) {
    for ( int j = 0 ;
    j < M ;
    j ++ ) {
      if ( d [ e [ j ] . from ] != INF && d [ e [ j ] . to ] > d [ e [ j ] . from ] + e [ j ] . cost ) {
        d [ e [ j ] . to ] = d [ e [ j ] . from ] + e [ j ] . cost ;
        if ( i >= N - 1 && e [ j ] . to == N - 1 ) return true ;
      }
    }
  }
  return false ;
}

static boolean bellmanFord ( ) { for ( int i = 0 ; i < MAX ; i ++ ) { d [ i ] = INF ; } d [ 0 ] = 0 ; for ( int i = 0 ; i < 2 * N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( d [ e [ j ] . from ] != INF && d [ e [ j ] . to ] > d [ e [ j ] . from ] + e [ j ] . cost ) { d [ e [ j ] . to ] = d [ e [ j ] . from ] + e [ j ] . cost ; if ( i >= N - 1 && e [ j ] . to == N - 1 ) return true ; } } } return false ; }
(method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters) body: (block (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 (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier))) update: (update_expression (identifier)) body: (block (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 (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (field_access object: (array_access array: (identifier) index: (identifier)) field: (identifier))) right: (identifier)) right: (binary_expression left: (array_access array: (identifier) index: (field_access object: (array_access array: (identifier) index: (identifier)) field: (identifier))) right: (binary_expression left: (array_access array: (identifier) index: (field_access object: (array_access array: (identifier) index: (identifier)) field: (identifier))) right: (field_access object: (array_access array: (identifier) index: (identifier)) field: (identifier)))))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (field_access object: (array_access array: (identifier) index: (identifier)) field: (identifier))) right: (binary_expression left: (array_access array: (identifier) index: (field_access object: (array_access array: (identifier) index: (identifier)) field: (identifier))) right: (field_access object: (array_access array: (identifier) index: (identifier)) field: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (field_access object: (array_access array: (identifier) index: (identifier)) field: (identifier)) right: (binary_expression left: (identifier) right: (decimal_integer_literal))))) consequence: (return_statement (true))))))))) (return_statement (false))))