private CodeBlock[] fromGraphToSubs(TaskMonitor monitor) throws CancelledException {

		DirectedGraph[] components = g.getComponents();
		CodeBlock[] subs = new CodeBlock[components.length];

		// Build the CodeBlock for each Model-P subroutine
		for (int i = 0; i < subs.length; i++) {

			if (monitor.isCancelled()) {
				throw new CancelledException();
			}

			GraphIterator<Vertex> vertIter = components[i].vertexIterator();
			AddressSet addrSet = new AddressSet();
			Address entry = null;

			// Follow all vertex references to build subroutine address set.
			// One of the vertices will be tagged as an entry point for each subroutine
			while (vertIter.hasNext()) {
				Vertex v = vertIter.next();
				CodeBlock block = (CodeBlock) g.getReferent(v);
				try {
					// check for entry point attribute
					int ix = entAttribute.getValue(v);
					Address[] entryPts = block.getStartAddresses();
					entry = entryPts[ix];
				}
				catch (NoValueException e) {
					// entry point not in this block/vertex
				}
				addrSet.add(block);
			}
			// Fabricate entry point if necessary
			if (entry == null) {
				entry = addrSet.getMinAddress();
				Msg.warn(this,
					"WARNING: fabricating entry point for Partitioned subroutine at " + entry);
			}
			subs[i] = createSub(addrSet, entry);
		}

		// delete all edges and verteces and attributes from graph
		entAttribute.clear();
		vertexAttributes.removeAttribute(ENTRY_POINT_TAG);
		vertexAttributes.removeAttribute(SOURCE_NUMBER);
		g.clear();

		return subs;
	}
Extract Model-P subroutines from Model-M subroutine graph following
call to partitionGraph().
@param monitor task monitor which allows user to cancel operation.
@return array of Model-P subroutine blocks.
@throws CancelledException if the monitor cancels the operation.
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/block/PartitionCodeSubModel.java