using the code, g for g in graphs.trees(10) we get the trees on 10 vertices. Now from this collection how we obtain only those trees having 5 pendant vertices and also find the tree(from those having 5 pendant vertices) having largest algebraic connectivity