How to use getJobsGraph method in Pipeline script

Is there any way to use getJobsGraph() method and than vertexSet() in Pipeline Script?. I’m now rewrite my old code from dsl files which where used in Build Flow plugin recently. I need to upgrade my Jenkins to 2.289.2 This is why I need to stop using Build Flow Plugin and start with Pipeline plugin.
I have loop like this:
for (item in build.getJobsGraph().vertexSet())
if (item.getBuild().getNextBuild() == null)
if (item.getBuild().getResult() != SUCCESS)
It must be translate to syntax understandable for Pipeline plugin.
Thanks for all yours answer

Uh. I’m trying to figure out what its trying to do to make a guess at what you should replace it with.

Is it just looping through all jobs until it finds the last one, then sets the current one to that status?

If so it’s a pretty obscure scenario and I’d like to know more about it’s purpose

Hi Gavin,
Thanks for replay.
Due to the lack of time, I had to abandon the problem that my post concerns for some time.
Loop is only an example not very good but still just an example of where I found the use of getJobsGraph() function.
The function was available when I was using the build flow plugin in an older version of Jenkins.
In Jenkins to 2.289.2 I need to use Pipeline instead of build flow plugin.
I need to rewrite the code in my dsl files to one that conforms to Pipeline syntax.
I’m looking for an equivalent for getJobsGraph() function in Pipeline.
Sorry for any confusion about the code I posted as a usage example earlier.