private List<CodeBlockVertex> createVertices(Function function, Program program,
			TaskMonitor monitor) throws CancelledException {
		List<CodeBlockVertex> vertices = new ArrayList<>();
		CodeBlockModel blockModel = new BasicBlockModel(program);

		AddressSetView addresses = function.getBody();
		CodeBlockIterator iterator = blockModel.getCodeBlocksContaining(addresses, monitor);
		monitor.initialize(addresses.getNumAddresses());

		for (; iterator.hasNext();) {
			monitor.checkCancelled();
			CodeBlock codeBlock = iterator.next();
			CodeBlockVertex vertex = new CodeBlockVertex(codeBlock);
			vertices.add(vertex);

			long blockAddressCount = codeBlock.getNumAddresses();
			long currentProgress = monitor.getProgress();
			monitor.setProgress(currentProgress + blockAddressCount);
		}

		return vertices;
	}
This plugin class contains the structure needed for the user to select code
blocks that are only reachable by following the flow from the current program
location (they are unreachable from any other starting point).
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/select/flow/SelectByScopedFlowPlugin.java