// verifyControlFlowGraphs is an helper method for tests to check if the generated expectedCfGraph
// is equal the actual graph.
func VerifyControlFlowGraphs(expectedCfGraph *cfgraph.ControlFlowGraph, correctCfGraph *graph.Graph) error {
	if expectedCfGraph.GetNumberOfNodes() != correctCfGraph.GetNumberOfNodes() {
		return fmt.Errorf("Number of nodes in graph should be %d, but are %d!", correctCfGraph.GetNumberOfNodes(),
			expectedCfGraph.GetNumberOfNodes())
	}
	if expectedCfGraph.GetNumberOfEdges() != correctCfGraph.GetNumberOfEdges() {
		return fmt.Errorf("Number of edges in graph should be %d, but are %d!", correctCfGraph.GetNumberOfEdges(),
			expectedCfGraph.GetNumberOfEdges())
	}

	for key, correctNode := range correctCfGraph.Nodes {
		if expectedNode, ok := expectedCfGraph.Nodes[key]; ok {
			//Node exist in graph, now check its edges.
			for index, correctEdge := range correctNode.GetOutNodes() {
				if correctNode.GetOutDegree() != expectedNode.GetOutDegree() {
					return fmt.Errorf("Node %s should have %d out-edges!\n", correctNode, correctNode.GetOutDegree())
				}
				if correctEdge.UID() != expectedNode.GetOutNodes()[index].UID() {
					return fmt.Errorf("Edge ( %s -> %s ) should not be present!", correctNode, correctEdge.Value)
				}
			}

		} else {
			return fmt.Errorf("Node %s is not found in the graph!", correctNode)
		}
	}
	return nil
}
func GetCyclomaticComplexity(cfg *cfgraph.ControlFlowGraph) int {
	return cfg.GetNumberOfEdges() - cfg.GetNumberOfNodes() + cfg.GetNumberOfSCComponents()
}