for ($i = 0; $i < $size; $i++){
  push @lowdeg, 2;
}

$comp = 2;
while ($graph eq 'DNE' || $comp > 1){
  @deg = ();
  for ($i = 0; $i < $size; $i++){
    push @deg, random($lowdeg[$i],$size - 1,2);
  }
  $graph = GRgraph_degrees(@deg);
  $comp = GRncomponents_graph($graph);

  do {
    $diff = random (0, $size - 1, 1);
  } until ($lowdeg[$diff] < $size - 2);
  $lowdeg[$diff] += 2;
}
while ($graph eq 'DNE' || $ans == 1){
  @deg = ();
  for ($i = 0; $i < $size; $i++){
    push @deg, random($lowdeg[$i],$size - 1,1);
  }
  $graph = GRgraph_degrees(@deg);
  if ($graph ne 'DNE'){
    @ans = GRiseulertrail_graph($graph);
  }

  do {
  $diff = random (0, $size - 1, 1);
  } until ($lowdeg[$diff] < $size - 1);
  $lowdeg[$diff]++;
}