Detects cycles in the given graph.

@return {@code true} if any cycles were detected
193546
public boolean findAndReportCycles(DependencyGraph graph) {
    this.graph = graph;
    cycleDetected = false;
    visitedEdge = new LinkedHashMap<Key<?>, Dependency>(graph.size());
    
    for (Key<?> key : graph.getAllKeys()) {
      visit(key, null);
    }

    return cycleDetected;
  }
663005
final boolean detectInheritanceCycle() {
    if (detectImplicitPrototypeCycle()
        || Iterables.contains(this.getCtorImplementedInterfaces(), this)) {
        return true;
    }
    FunctionType fnType = this.getConstructor();
    return fnType != null && fnType.checkExtendsLoop() != null;
  }
110269
public static <T> Set<Set<Node<T>>> compute(final Graph<T> graph) {
    final Set<Set<Node<T>>> connectedComponents = new LinkedHashSet<>();
    final Set<Node<T>> unmarkedNodes = new LinkedHashSet<>(graph.nodes());

    while (!unmarkedNodes.isEmpty()) {
      Set<Node<T>> connectedComp = new LinkedHashSet<>();
      deepFirstSearch(unmarkedNodes.iterator().next(), connectedComp, unmarkedNodes);
      connectedComponents.add(connectedComp);
    }

    return connectedComponents;
  }
450063
public Map relevantCycles() {
        Map result = new HashMap();
        //minimize();

        for (SimpleCycleBasis subgraphBase : subgraphBases) {
            SimpleCycleBasis cycleBasis = subgraphBase;
            result.putAll(cycleBasis.relevantCycles());
        }

        return result;
    }
647406
private static boolean isTree(int n, boolean[][] chart) {
        if (!chart[0][n]) {
            // Root must be a span.
            return false;
        }
        for (int width = 1; width <= n; width++) {
            for (int start = 0; start <= n - width; start++) {
                int end = start + width;
                if (width == 1) {
                    if (!chart[start][end]) {
                        // All width 1 spans must be set.
                        return false;
                    }
                } else {
                    if (chart[start][end]) {
                        // Count the number of pairs of child spans which could have been combined to form this span.
                        int childPairCount = 0;
                        for (int mid = start + 1; mid <= end - 1; mid++) {
                            if (chart[start][mid] && chart[mid][end]) {
                                childPairCount++;
                            }
                        }
                        if (childPairCount != 1) {
                            // This span should have been built from exactly one pair of child spans.
                            return false;
                        }
                    }
                }
            }
        }
        return true;
    }
378650
@Override
    public boolean isSubgraph(boolean shouldMatchBonds) {

        CDKRMapHandler rmap = new CDKRMapHandler();

        try {

            if ((source.getAtomCount() == target.getAtomCount()) && source.getBondCount() == target.getBondCount()) {
                rOnPFlag = true;
                rmap.calculateIsomorphs(source, target, shouldMatchBonds);

            } else if (source.getAtomCount() > target.getAtomCount() && source.getBondCount() != target.getBondCount()) {
                rOnPFlag = true;
                rmap.calculateSubGraphs(source, target, shouldMatchBonds);

            } else {
                rOnPFlag = false;
                rmap.calculateSubGraphs(target, source, shouldMatchBonds);
            }

            setAllMapping();
            setAllAtomMapping();
            setFirstMapping();
            setFirstAtomMapping();

        } catch (CDKException e) {
            rmap = null;
            //            System.err.println("WARNING: graphContainer: most probably time out error ");
        }

        return !getFirstMapping().isEmpty();
    }
874584
int checkNumberOfConnections( List<SquareNode> graph ) {
		int histogram[] = new int[5];

		for (int i = 0; i < graph.size(); i++) {
			histogram[ graph.get(i).getNumberOfConnections() ]++;
		}

		if( graph.size() == 1 ) {
			if( histogram[0] != 1 )
				return 0;

			return 1;
		} else if( histogram[1] == 2 ) {
			// line
			if( histogram[0] != 0 )
				return 0;
			if( histogram[2] != graph.size()-2 )
				return 0;
			if( histogram[3] != 0 )
				return 0;
			if( histogram[4] != 0 )
				return 0;

			return 1;
		} else {
			// grid
			if (histogram[0] != 0)
				return 0;
			if (histogram[1] != 0)
				return 0;
			if (histogram[2] != 4)
				return 0;
			return 2;
		}
	}
1178732
def _detect_loops(self, loop_callback=None):
        

        loop_finder = self.project.analyses.LoopFinder(kb=self.kb, normalize=False, fail_fast=self._fail_fast)

        if loop_callback is not None:
            graph_copy = networkx.DiGraph(self._graph)

            for loop in loop_finder.loops:  # type: angr.analyses.loopfinder.Loop
                loop_callback(graph_copy, loop)

            self.model.graph = graph_copy

        # Update loop backedges and graph
        self._loop_back_edges = list(itertools.chain.from_iterable(loop.continue_edges for loop in loop_finder.loops))
923762
public boolean isInstanceDependencyChainAcyclic() {

		final AbstractJobVertex[] allVertices = this.getAllJobVertices();
		final Set<AbstractJobVertex> alreadyVisited = new HashSet<AbstractJobVertex>();

		for (AbstractJobVertex vertex : allVertices) {

			if (alreadyVisited.contains(vertex)) {
				continue;
			}

			AbstractJobVertex vertexToShareInstancesWith = vertex.getVertexToShareInstancesWith();
			if (vertexToShareInstancesWith != null) {

				final Set<AbstractJobVertex> cycleMap = new HashSet<AbstractJobVertex>();

				while (vertexToShareInstancesWith != null) {

					if (cycleMap.contains(vertexToShareInstancesWith)) {
						return false;
					} else {
						alreadyVisited.add(vertexToShareInstancesWith);
						cycleMap.add(vertexToShareInstancesWith);
						vertexToShareInstancesWith = vertexToShareInstancesWith.getVertexToShareInstancesWith();
					}
				}
			}
		}

		return true;
	}
801317
private void checkForCycles(Class<?> target) {
        Stack<Class<?>> trace = new Stack<>();
        trace.push(target);
        checkForCycles(target, target, trace);
    }
387782
public List<Set<T>> getCycles() {
        return scc.stream().filter(cc ->
                cc.size() > 1
                        || graph.get(Iterables.getOnlyElement(cc)).contains(Iterables.getOnlyElement(cc))
        )
                .collect(Collectors.toList());
    }
889293
@Override
  public boolean visit(final JavaInstance<?> node) {
    this.graphStr
        .append("  \"")
        .append(node.getClass())
        .append('_')
        .append(node.getNode().getName())
        .append("\" [label=\"")
        .append(node.getNode().getName())
        .append(" = ")
        .append(node.getInstanceAsString())
        .append("\", shape=box, style=bold];\n");
    return true;
  }
646328
@Override
	public boolean process(PairwiseImageGraph pairwiseGraph ) {
		this.graph = new MetricSceneGraph(pairwiseGraph);
		for (int i = 0; i < graph.edges.size(); i++) {
			decomposeEssential(graph.edges.get(i));
		}

		declareModelFitting();

		for (int i = 0; i < graph.edges.size(); i++) {
			Motion e = graph.edges.get(i);
			e.triangulationAngle = medianTriangulationAngle(e);
		}

		if( verbose != null )
			verbose.println("Selecting root");
		// Select the view which will act as the origin
		View origin = selectOriginNode();
		// Select the motion which will define the coordinate system
		Motion baseMotion = selectCoordinateBase( origin );

		this.graph.sanityCheck();

		if( verbose != null )
			verbose.println("Stereo triangulation");
		// Triangulate features in all motions which exceed a certain angle
		for (int i = 0; i < graph.edges.size() && !stopRequested ; i++) {
			Motion e = graph.edges.get(i);
			if( e.triangulationAngle > Math.PI/10 || e == baseMotion) {
				triangulateStereoEdges(e);
				if( verbose != null ) {
					int a = e.viewSrc.index;
					int b = e.viewDst.index;
					verbose.println("   Edge[" + i + "] "+a+"->"+b+"  feat3D="+e.stereoTriangulations.size());
				}
			}
		}
		if( stopRequested )
			return false;

		if( verbose != null )
			verbose.println("Defining the coordinate system");

		// Using the selecting coordinate frames and triangulated points define the coordinate system
		defineCoordinateSystem(origin, baseMotion);
		if( stopRequested )
			return false;

		if( verbose != null )
			verbose.println("Estimate all features");

		// Now estimate all the other view locations and 3D features
		estimateAllFeatures(origin, baseMotion.destination(origin));
		if( stopRequested )
			return false;

		// Convert the graph into the output format
		convertToOutput(origin);

		return viewsAdded.size() >= 2;
	}
402136
@Override
	public boolean check(EmbeddedBrowser browser) {
		if (condition.check(browser)) {
			count.getAndIncrement();
		}
		return count.get() <= maxCount;
	}
76722
public boolean notifyIndeterminantProgress() {

    boolean result = true;

    for (ProgressMonitor monitor : this.monitors) {
      if (!monitor.notifyIndeterminantProgress()) {
        result = false;
      }
    }

    return result;

  }
889042
public boolean process() {
		if( graph.nodes.size() < 2 )
			return false;
		stopRequested = false;

		declareModelFitting();

		for (int i = 0; i < graph.nodes.size(); i++) {
			if( verbose != null )
				verbose.print("Matching node "+i+" -> ");
			associate.setSource(graph.nodes.get(i).descriptions);
			for (int j = i+1; j < graph.nodes.size(); j++) {
				associate.setDestination(graph.nodes.get(j).descriptions);
				associate.associate();
				if( associate.getMatches().size < MIN_FEATURE_ASSOCIATED )
					continue;

				boolean connected = connectViews(graph.nodes.get(i),graph.nodes.get(j),associate.getMatches());
				if( verbose != null ) {
					if( connected )
						verbose.print("+");
					else
						verbose.print("-");
				}

				if( stopRequested )
					return false;
			}
			if( verbose != null ) {
				verbose.println();
			}
		}
		return graph.edges.size() >= 1;
	}
1101934
@Override
  public boolean visit(final NamedParameterNode<?> node) {
    this.graphStr
        .append("  ")
        .append(node.getName())
        .append(" [label=\"")
        .append(node.getSimpleArgName())           // parameter type, e.g. "Integer"
        .append("\\n")
        .append(node.getName())                    // short name, e.g. "NumberOfThreads"
        .append(" = ")
        .append(config.getNamedParameter(node))   // bound value, e.g. "16"
        .append("\\n(default = ")
        .append(instancesToString(node.getDefaultInstanceAsStrings())) // default value, e.g. "4"
        .append(")\", shape=oval];\n");
    return true;
  }