@Override
	public void run(TaskMonitor monitor) {
		GraphType graphType = new PCodeCfgGraphType();

		// get a new graph
		AttributedGraph graph = new AttributedGraph("PCode Graph", graphType);
		try {
			monitor.setMessage("Computing Graph...");
			if (pcodeGraphType == PcodeGraphSubType.DATA_FLOW_GRAPH) {
				createDataFlowGraph(graph, monitor);
			}
			else {
				createControlFlowGraph(graph, monitor);
			}

			GraphDisplay display = graphService.getDefaultGraphDisplay(!newGraph, monitor);

			PCodeCfgDisplayListener displayListener =
				new PCodeCfgDisplayListener(tool, display, hfunction, pcodeGraphType);
			display.setGraphDisplayListener(displayListener);

			monitor.setMessage("Obtaining handle to graph provider...");
			if (monitor.isCancelled()) {
				return;
			}
			monitor.setCancelEnabled(false);

			monitor.setMessage("Rendering Graph...");

			String description =
				pcodeGraphType == PcodeGraphSubType.DATA_FLOW_GRAPH ? "AST Data Flow"
						: "AST Control Flow";
			description = description + " for " + hfunction.getFunction().getName();
			GraphDisplayOptions graphDisplayOptions =
				new ProgramGraphDisplayOptions(new PCodeCfgGraphType(), tool);
			graphDisplayOptions.setVertexLabelOverrideAttributeKey(CODE_ATTRIBUTE);
			display.setGraph(graph, graphDisplayOptions, description, false, monitor);
			setGraphLocation(display, displayListener);
		}
		catch (GraphException e) {
			Msg.showError(this, null, "Graph Error",
				"Can't create graph display: " + e.getMessage());
		}
		catch (CancelledException e1) {
			return;
		}

	}
Task to create a PCode control flow graph based on decompiler output
Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/PCodeCfgGraphTask.java