I know that Select[] is some sort of Mathematica function that works with lists. However, I need to be able to grab each element by name into a variable so that I can use it just like in a ForEach loop. Below, you can see that I converted one of my loops into a Select, but I have two more nested ones. Mathematica states that it has full procedural potential, but it does not have the ForEach loop, which makes it much more difficult to operate (do more than one function/action on) each element in some given loop. Even if this could be converted into a functional list to be printed after, I'd rather have something that can print as it finds applicable graphs.
For[x = 0, x < 5, x = x + 1,
n = RandomInteger[{1, 10}];
m = RandomInteger[{n - 1, n * (n - 1) / 2}];
G = RandomGraph[{n, m}];
R = Radius[G];
V = VertexList[G];
P = Select[V, R + 1 == VertexEccentricity[G, #]];
ForEach [p, P,
N = AdjacencyList[G, p];
test = true;
ForEach[n, N,
If[VertexEccentricity[G, n] == R,
test = false;
];
];
If [test == true,
Print[G]
]
]
]