# File Sode.tmp.rb, line 255
def determine_priority
  pass = 1
  change = 1
  $max_priority = 0
  while pass == 1 do
    change = 0
    $eq_dep_data.each_key {|id|
#      puts "id = " + id
 #     puts $eq_dep_data[id].degree.to_s
      $eq_dep_data[id].rhs_dat.each_key {|id2|
        if $eq_dep_data[id].degree.to_i + $eq_dep_data[id].priority.to_i < $eq_dep_data[id].rhs_dat_val(id2).to_i + $eq_dep_data[id2].priority.to_i + 1

          if pass == 1 then
            $eq_dep_data[id].priority =  $eq_dep_data[id].rhs_dat_val(id2).to_i - $eq_dep_data[id].degree.to_i + $eq_dep_data[id2].priority.to_i + 1
            if $eq_dep_data[id].priority > $max_priority then
              $max_priority = $eq_dep_data[id].priority
            end

            change = 1
          end
        end
        if $eq_dep_data[id].priority > 9999 then  # if circular will increase indefinitely
          puts "Inconsistent dependencies"
          $stderr.puts "Inconsistent dependencies"
          exit 1
#          puts "id2 = " + id2
#          puts "$eq_dep_data[id].rhs_dat[id2] = " + $eq_dep_data[id].rhs_dat_val(id2).to_s
        end
      }
    }
    if change == 0 then
      if pass > 0 then
        return
      end
      pass += 1
    else
      pass = 0
    end
  end
end