Question: How to get a procedure to return an output as a {set}?

So if I have a procedure like 

with(GraphTheory)

tneighbors := proc (G::Graph)

local numvertices::integer, i::integer, currentvertex;

numvertices := nops(Vertices(G));

for i to numvertices do

currentvertex := Vertices(G)[i];

if nops(Neighbors(G, currentvertex)) = 2 then print(currentvertex)

end if;

end do;

end proc;

How do I make it so the output gets returned as a set?

For example, if I do  twoneighbors(G); and get
1

7

4

How do I make it so the output is listed as a set like {1,4,7}? Thanks.

Please Wait...