<commit_before>package uk.ac.kent.dover.fastGraph.profiling;

import java.util.*;

import uk.ac.kent.dover.fastGraph.*;
import uk.ac.kent.dover.fastGraph.editOperation.*;
import uk.ac.kent.dover.fastGraph.graphSimilarity.*;

public class ProfileGED {

	public static void main(String [] args) {
		
		Debugger.enabled = false;
		
		profileRandomGraphsWithEdits();
		
	}
	
	

	protected static void profileRandomGraphsWithEdits() {
		try {
			
			Debugger.enabled = false;
			
			ArrayList<String> labels = new ArrayList<>();
			labels.add("blue");
			labels.add("black");
			labels.add("green");

			long startTime,simpleTime,bipartiteTime;
			Random r;
			final int iterations = 20;
			final int startNodes = 10000;
			final int startEdges = startNodes*10;
			final int startEdits = 20;
			final boolean directed = false;
			final boolean labelled = true;
			final boolean simple = true;
			
			int nodes = 0;
			int edges = 0;
			int edits = 0;

			while(nodes < 10000000) {
				nodes += startNodes;
				edges += startEdges;
				edits += startEdits;
				for(int i = 1; i <= iterations; i++) {
					
					long seed1 = System.currentTimeMillis()*i*nodes;
					long seed2 = System.currentTimeMillis()*i*nodes*1199;
					long seed3 = System.currentTimeMillis()*i*nodes*3311;
					long seed4 = System.currentTimeMillis()*i*nodes*7711;
					long seed5 = System.currentTimeMillis()*i*nodes*1177;
					long seed6 = System.currentTimeMillis()*i*nodes*4477;
					
					FastGraph g1 = FastGraph.randomGraphFactory(10, 15, seed1, simple, false);
					
					r = new Random(seed6);
					HashMap<Integer,Double> editCosts = new HashMap<>();
					editCosts.put(EditOperation.DELETE_NODE,(double)(r.nextInt(10)+1));
					editCosts.put(EditOperation.ADD_NODE,(double)(r.nextInt(10)+1));
					editCosts.put(EditOperation.DELETE_EDGE,(double)(r.nextInt(10)+1));
					editCosts.put(EditOperation.ADD_EDGE,(double)(r.nextInt(10)+1));
					editCosts.put(EditOperation.RELABEL_NODE,(double)(r.nextInt(10)+1));
				
					r = new Random(seed3);
					for(int n = 0; n < g1.getNumberOfNodes(); n++) {
						String label = labels.get(r.nextInt(labels.size()));
						g1 = g1.generateGraphByRelabellingNode(n, label);
					}
					
					EditList el = EditList.generateEditList(g1,edits,labels,editCosts, seed2);

					FastGraph g2 = el.applyOperations(g1);
					g2 = ExactIsomorphism.generateRandomIsomorphicGraph(g2, seed5, false);
					
					startTime = System.currentTimeMillis();
					ApproximateGEDSimple simpleGED = new ApproximateGEDSimple(directed, labelled, editCosts, 1000, 0, seed4);
					double simpleSimilarity = simpleGED.similarity(g1, g2);
					simpleTime = System.currentTimeMillis()-startTime;

					startTime = System.currentTimeMillis();
					ApproximateGEDBipartite bipartiteGED = new ApproximateGEDBipartite(directed,labelled,editCosts);
					double bipartiteSimilarity = bipartiteGED.similarity(g1, g2);
					bipartiteTime = System.currentTimeMillis()-startTime;

					System.out.print("nodes\t"+nodes+"\tedges\t"+edges+"\tedits\t"+edits+"\tdirected\t"+directed+"\tlabelled\t"+labelled+"\tsimple\t"+simple+"\t");
					System.out.print(i + "\toriginal cost:\t"+el.getCost()+"\tsimple cost:\t"+simpleSimilarity+"\tbipartite cost:\t"+bipartiteSimilarity+"\t");
					System.out.println("original time:\t-1.0"+"\tsimple time:\t"+(simpleTime/1000.0)+"\tbipartite time:\t"+(bipartiteTime/1000.0));
					
				}

			}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	protected static void profileSimpleBipartite() {
		try {

			long startTime,GEDTime;
			final int iterations = 100;
			final int startNodes = 5;
			final boolean directed = false;
			final boolean labelled = true;
			final boolean simple = true;

			System.out.println("startNodes\t"+startNodes+"\tdirected\t"+directed+"\tlabelled\t"+labelled+"\tsimple\t"+simple);

			for(int i = 1; i <= iterations; i++) {
//i = 3;
				int nodes = i*startNodes;<commit_msg>added Hausdorff and Lower Bounds methods to profiling<commit_after>package uk.ac.kent.dover.fastGraph.profiling;

import java.util.*;

import uk.ac.kent.dover.fastGraph.*;
import uk.ac.kent.dover.fastGraph.editOperation.*;
import uk.ac.kent.dover.fastGraph.graphSimilarity.*;

public class ProfileGED {

	public static void main(String [] args) {
		
		Debugger.enabled = false;
		
		profileRandomGraphsWithEdits();
		
	}
	
	

	protected static void profileRandomGraphsWithEdits() {
		try {
			
			Debugger.enabled = false;
			
			ArrayList<String> labels = new ArrayList<>();
			labels.add("blue");
			labels.add("black");
			labels.add("green");

			long startTime,simpleTime,bipartiteTime,hausdorffTime,lowerTime;
			Random r;
			final int iterations = 20;
			final int startNodes = 10000;
			final int startEdges = startNodes*10;
			final int startEdits = 20;
			final boolean directed = false;
			final boolean labelled = true;
			final boolean simple = true;
			
			int nodes = 0;
			int edges = 0;
			int edits = 0;

			while(nodes < 10000000) {
				nodes += startNodes;
				edges += startEdges;
				edits += startEdits;
				for(int i = 1; i <= iterations; i++) {
					
					long seed1 = System.currentTimeMillis()*i*nodes;
					long seed2 = System.currentTimeMillis()*i*nodes*1199;
					long seed3 = System.currentTimeMillis()*i*nodes*3311;
					long seed4 = System.currentTimeMillis()*i*nodes*7711;
					long seed5 = System.currentTimeMillis()*i*nodes*1177;
					long seed6 = System.currentTimeMillis()*i*nodes*4477;
					
					FastGraph g1 = FastGraph.randomGraphFactory(10, 15, seed1, simple, false);
					
					r = new Random(seed6);
					HashMap<Integer,Double> editCosts = new HashMap<>();
					editCosts.put(EditOperation.DELETE_NODE,(double)(r.nextInt(10)+1));
					editCosts.put(EditOperation.ADD_NODE,(double)(r.nextInt(10)+1));
					editCosts.put(EditOperation.DELETE_EDGE,(double)(r.nextInt(10)+1));
					editCosts.put(EditOperation.ADD_EDGE,(double)(r.nextInt(10)+1));
					editCosts.put(EditOperation.RELABEL_NODE,(double)(r.nextInt(10)+1));
				
					r = new Random(seed3);
					for(int n = 0; n < g1.getNumberOfNodes(); n++) {
						String label = labels.get(r.nextInt(labels.size()));
						g1 = g1.generateGraphByRelabellingNode(n, label);
					}
					
					EditList el = EditList.generateEditList(g1,edits,labels,editCosts, seed2);

					FastGraph g2 = el.applyOperations(g1);
					g2 = ExactIsomorphism.generateRandomIsomorphicGraph(g2, seed5, false);
					
					startTime = System.currentTimeMillis();
					ApproximateGEDSimple simpleGED = new ApproximateGEDSimple(directed, labelled, editCosts, 1000, 0, seed4);
					double simpleSimilarity = simpleGED.similarity(g1, g2);
					simpleTime = System.currentTimeMillis()-startTime;

					startTime = System.currentTimeMillis();
					ApproximateGEDBipartite bipartiteGED = new ApproximateGEDBipartite(directed,labelled,editCosts);
					double bipartiteSimilarity = bipartiteGED.similarity(g1, g2);
					bipartiteTime = System.currentTimeMillis()-startTime;
					
					double hausdorffSimilarity = -1;
					hausdorffTime = -1;
					if(!directed) {
						startTime = System.currentTimeMillis();
						ApproximateGEDHausdorff hausdorffGED = new ApproximateGEDHausdorff(labelled,editCosts);
						hausdorffSimilarity = hausdorffGED.similarity(g1, g2);
						hausdorffTime = System.currentTimeMillis()-startTime;
					}

					double lowerSimilarity = -1;
					lowerTime = -1;
					if(!directed) {
						startTime = System.currentTimeMillis();
						ApproximateGEDLowerBoundsSimple lowerGED = new ApproximateGEDLowerBoundsSimple(labelled,editCosts);
						lowerSimilarity = lowerGED.similarity(g1, g2);
						lowerTime = System.currentTimeMillis()-startTime;
					}

					System.out.print("nodes\t"+nodes+"\tedges\t"+edges+"\tedits\t"+edits+"\tdirected\t"+directed+"\tlabelled\t"+labelled+"\tsimple\t"+simple+"\t");
					System.out.print(i + "\toriginal cost:\t"+el.getCost()+"\tsimple cost:\t"+simpleSimilarity+"\tbipartite cost:\t"+bipartiteSimilarity+"\t"+"\thausdorff cost:\t"+hausdorffSimilarity+"\t"+"\tlower cost:\t"+lowerSimilarity+"\t");
					System.out.println("original time:\t-1.0"+"\tsimple time:\t"+(simpleTime/1000.0)+"\tbipartite time:\t"+(bipartiteTime/1000.0)+"\thausdorff time:\t"+(hausdorffTime/1000.0)+"\tlower time:\t"+(lowerTime/1000.0));
					
				}

			}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	protected static void profileSimpleBipartite() {
		try {

			long startTime,GEDTime;
			final int iterations = 100;
			final int startNodes = 5;
			final boolean directed = false;
			final boolean labelled = true;
			final boolean simple = true;

			System.out.println("startNodes\t"+startNodes+"\tdirected\t"+directed+"\tlabelled\t"+labelled+"\tsimple\t"+simple);

			for(int i = 1; i <= iterations; i++) {
//i = 3;
				int nodes = i*startNodes;
{'fraction_non_alphanumeric': 0.13893633982462134, 'fraction_numerical': 0.027331738981892725, 'mean_word_length': 3.9254066180594505, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3105460', 'n_tokens_mistral': 3734, 'n_tokens_neox': 2881, 'n_words': 514}