<commit_before>/******************************************************************************
 *                                                                             *
 *  Copyright: (c) Syncleus, Inc.                                              *
 *                                                                             *
 *  You may redistribute and modify this source code under the terms and       *
 *  conditions of the Open Source Community License - Type C version 1.0       *
 *  or any later version as published by Syncleus, Inc. at www.syncleus.com.   *
 *  There should be a copy of the license included with this file. If a copy   *
 *  of the license is not included you are granted no right to distribute or   *
 *  otherwise use this file except through a legal and valid license. You      *
 *  should also contact Syncleus, Inc. at the information below if you cannot  *
 *  findCycles a license:                                                            *
 *                                                                             *
 *  Syncleus, Inc.                                                             *
 *  2604 South 12th Street                                                     *
 *  Philadelphia, PA 19148                                                     *
 *                                                                             *
 ******************************************************************************/
package com.syncleus.dann.graph.cycle;

import com.syncleus.dann.graph.*;
import java.util.*;

public class ExhaustiveDepthFirstSearchCycleFinder<N, E extends Edge<N>> extends ColoredDepthFirstSearchDetector implements CycleFinder<N,E>
{
	public boolean isPancyclic(Graph<N,E> graph)
	{
		if(!graph.isSimple())
			return false;
		
		final int graphOrder = graph.getOrder();
		Set<Cycle<N,E>> cycles = this.findCycles(graph);
		SortedSet<Cycle<N,E>> sortedCycles = new TreeSet<Cycle<N,E>>(new CycleLengthComparator<N,E>());
		sortedCycles.addAll(cycles);

		int neededCycleSize = 3;
		for(Cycle<N,E> sortedCycle : sortedCycles)
		{
			int currentCycleSize = sortedCycle.getLength();
			if(currentCycleSize == neededCycleSize)
			{
				if(currentCycleSize == graphOrder)
					return true;
				else
					neededCycleSize++;
			}
			else if(currentCycleSize > neededCycleSize)
				return false;
		}
		return false;
	}

	public boolean isUnicyclic(Graph<N,E> graph)
	{
		return (this.findCycles(graph).size() == 1);
	}

	public int cycleCount(Graph<N,E> graph)
	{
		return this.findCycles(graph).size();
	}

	public int girth(Graph<N,E> graph)
	{
		Set<Cycle<N,E>> cycles = this.findCycles(graph);
		SortedSet<Cycle<N,E>> sortedCycles = new TreeSet<Cycle<N,E>>(new CycleLengthComparator<N,E>());
		sortedCycles.addAll(cycles);
		return sortedCycles.first().getLength();
	}<commit_msg>Changed isUnicyclic in Graph and in CycleFinder to restrict only to simple graphs<commit_after>/******************************************************************************
 *                                                                             *
 *  Copyright: (c) Syncleus, Inc.                                              *
 *                                                                             *
 *  You may redistribute and modify this source code under the terms and       *
 *  conditions of the Open Source Community License - Type C version 1.0       *
 *  or any later version as published by Syncleus, Inc. at www.syncleus.com.   *
 *  There should be a copy of the license included with this file. If a copy   *
 *  of the license is not included you are granted no right to distribute or   *
 *  otherwise use this file except through a legal and valid license. You      *
 *  should also contact Syncleus, Inc. at the information below if you cannot  *
 *  findCycles a license:                                                            *
 *                                                                             *
 *  Syncleus, Inc.                                                             *
 *  2604 South 12th Street                                                     *
 *  Philadelphia, PA 19148                                                     *
 *                                                                             *
 ******************************************************************************/
package com.syncleus.dann.graph.cycle;

import com.syncleus.dann.graph.*;
import java.util.*;

public class ExhaustiveDepthFirstSearchCycleFinder<N, E extends Edge<N>> extends ColoredDepthFirstSearchDetector implements CycleFinder<N,E>
{
	public boolean isPancyclic(Graph<N,E> graph)
	{
		if(!graph.isSimple())
			return false;
		
		final int graphOrder = graph.getOrder();
		Set<Cycle<N,E>> cycles = this.findCycles(graph);
		SortedSet<Cycle<N,E>> sortedCycles = new TreeSet<Cycle<N,E>>(new CycleLengthComparator<N,E>());
		sortedCycles.addAll(cycles);

		int neededCycleSize = 3;
		for(Cycle<N,E> sortedCycle : sortedCycles)
		{
			int currentCycleSize = sortedCycle.getLength();
			if(currentCycleSize == neededCycleSize)
			{
				if(currentCycleSize == graphOrder)
					return true;
				else
					neededCycleSize++;
			}
			else if(currentCycleSize > neededCycleSize)
				return false;
		}
		return false;
	}

	public boolean isUnicyclic(Graph<N,E> graph)
	{
		return ((this.findCycles(graph).size() == 1)&&(graph.isSimple()));
	}

	public int cycleCount(Graph<N,E> graph)
	{
		return this.findCycles(graph).size();
	}

	public int girth(Graph<N,E> graph)
	{
		Set<Cycle<N,E>> cycles = this.findCycles(graph);
		SortedSet<Cycle<N,E>> sortedCycles = new TreeSet<Cycle<N,E>>(new CycleLengthComparator<N,E>());
		sortedCycles.addAll(cycles);
		return sortedCycles.first().getLength();
	}
{'fraction_non_alphanumeric': 0.14012409513960702, 'fraction_numerical': 0.005170630816959669, 'mean_word_length': 1.8699307616221563, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 44, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5565939', 'n_tokens_mistral': 1642, 'n_tokens_neox': 1473, 'n_words': 398}