add whitespace after if. and don't do one liner if unless you are using if/else as ternary operator. here do

    if (nbrs(i) != vid) {
      set.add(nbrs(i))
    }