public static FGData createNewGraph(Function function, FGController controller, Program program,
			TaskMonitor monitor) throws CancelledException {

		FunctionGraph graph = createGraph(function, controller, monitor);
		if (graph.getVertices().size() == 0) {
			return new EmptyFunctionGraphData("No data in function: " + function.getName());
		}

		if (!isEntryPointValid(function, controller, monitor)) {
			return new EmptyFunctionGraphData(
				"No instruction at function entry point: " + function.getName());
		}

		FGVertex functionEntryVertex = graph.getVertexForAddress(function.getEntryPoint());
		graph.setRootVertex(functionEntryVertex);

		graph.setOptions(controller.getFunctionGraphOptions());

		// doing this here will keep the potentially slow work off of the Swing thread, as the
		// results are cached
		String errorMessage = layoutGraph(function, controller, graph, monitor);
		return new FGData(function, graph, errorMessage);
	}
Creates a new function graph for the given function

@param function the function to graph
@param controller the controller needed by the function graph
@param program the function's program
@param monitor the task monitor
@return the new graph
@throws CancelledException if the task is cancelled via the monitor
Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/graph/FunctionGraphFactory.java