bool Findk() { for (int k = 3; k <= 10; k++) { // Console.WriteLine("k=" + k); if (Triarc.DoesTriarcExist(k, k, k, FaceSizes, 100000)) { //Console.WriteLine(" Existuje (k,k,k)"); ks.Add(k); if (Triarc.DoesTriarcExist(k, k, k - 1, FaceSizes, 100000)) { ksMinusOne.Add(k); //Console.WriteLine(" Existuje (k,k,k-1)"); if (Bstrings != null) { foreach (var r in Bstrings) { if (A(r, k).Count() < 64 && Triarc.DoesGeneralBoundaryExist(Convert.ToInt64(A(r, k), 2), FaceSizes)) { // Console.WriteLine(" A s řetízkem " + r + " existuje"); this.k = k; this.AString = r; return(true); } } } } } } return(false); }
bool FindCD() { foreach (var R in strings) { if (Triarc.DoesGeneralBoundaryExist(Convert.ToInt64(C(R), 2), this.FaceSizes)) { if (Triarc.DoesGeneralBoundaryExist(Convert.ToInt64(D(R), 2), FaceSizes)) { CDString = R; return(true); } } } Console.WriteLine("CD řetízek nenalezen"); return(false); }
public void Find() { FindCD(); if (CDString != null || slow) { Bstrings = strings.Where(x => Triarc.DoesGeneralBoundaryExist(Convert.ToInt64(B(x), 2), FaceSizes)); } if ((Bstrings != null && Bstrings.Count() > 0 && CDString != null) || slow) { Findk(); } if (AString != null && CDString != null & k.HasValue) { found = true; Console.WriteLine("----------------------------------------"); Console.WriteLine("Nalezeno:"); Console.WriteLine("AB řetízek: " + AString); Console.WriteLine("CD řežízek: " + CDString); Console.WriteLine("k: " + k); Console.WriteLine(); Console.WriteLine("Saving all helping graphs"); Triarc.FindAndBuildTriarc(k.Value, k.Value, k.Value, FaceSizes, path + "(k,k,k)\\"); Triarc.FindAndBuildTriarc(k.Value, k.Value, k.Value - 1, FaceSizes, path + "(k,k,k-1)\\"); Triarc.DoesGeneralBoundaryExistAndConstruct(Convert.ToInt64(A(AString, k.Value), 2), FaceSizes, path + "A\\"); Triarc.DoesGeneralBoundaryExistAndConstruct(Convert.ToInt64(B(AString), 2), FaceSizes, path + "B\\"); Triarc.DoesGeneralBoundaryExistAndConstruct(Convert.ToInt64(C(CDString), 2), FaceSizes, path + "C\\"); Triarc.DoesGeneralBoundaryExistAndConstruct(Convert.ToInt64(D(CDString), 2), FaceSizes, path + "D\\"); StreamWriter info = new StreamWriter("grafy\\" + path + "info.txt"); info.WriteLine("Nalezeno:"); info.WriteLine("AB řetízek: " + AString); info.WriteLine("CD řežízek: " + CDString); info.WriteLine("k: " + k); info.Close(); } else { Console.WriteLine("----------------------------------------"); Console.WriteLine("Nenalezeno."); } }
/// <summary> /// GUI, doesn't support some features, depricated. /// </summary> static void GUI() { char whatToDo; bool end = false; while (!end) { WhatToDoMessage(); Console.WriteLine(); whatToDo = char.ToLower(Console.ReadKey().KeyChar); Console.WriteLine(); switch (whatToDo) { case 'e': #region Does triarc exist { int x; int y; int z; ReadTriarcSizes(out x, out y, out z); int limit = 0; bool limitEntered = false; while (!limitEntered) { Console.WriteLine("Enter limit that specifies how many boundaries to find before saying that triarc doesn't exist"); limitEntered = int.TryParse(Console.ReadLine(), out limit); } if (Triarc.DoesTriarcExist(x, y, z, ReadFaces(), limit)) { Console.WriteLine("Triarc exists!"); Console.WriteLine(); } else { Console.WriteLine("With this limit, triarc can't be found."); } } break; #endregion case 'r': #region Build and extract { int x; int y; int z; ReadTriarcSizes(out x, out y, out z); Triarc.FindAndBuildTriarc(x, y, z, ReadFaces()); } break; #endregion case 'a': #region all triarcs of given faces { try { int limit = 0; bool limitEntered = false; while (!limitEntered) { Console.WriteLine("Enter limit that specifies how many boundaries to find before saying that triarc doesn't exist (0 for default)"); limitEntered = int.TryParse(Console.ReadLine(), out limit); if (limit == 0) { limit = 100000; } } Triarc.DoTriarcsExist(Console.Out, ReadFaces(), limit); } catch (IOException) { Console.WriteLine("Invalid file name!"); } } break; #endregion case 'n': #region nnn { Console.WriteLine("Output will be in file (n,n,n)TriarcsWithFaces[...]"); int limit = 0; bool limitEntered = false; while (!limitEntered) { Console.WriteLine("Enter limit that specifies how many boundaries to find before saying that triarc doesn't exist"); Console.WriteLine("0 for short default limit, 1 for medium default, 2 for long default"); limitEntered = int.TryParse(Console.ReadLine(), out limit); if (limit == 0) { limit = 100000; } if (limit == 1) { limit = 1000000; } if (limit == 2) { limit = 10000000; } } Triarc.Do_nnn_TriarcsExist(ReadFaces(), limit); } break; #endregion case 'm': #region nnn-1 { Console.WriteLine("Output will be in file (n,n,n-1)TriarcsWithFaces[...]"); int limit = 0; bool limitEntered = false; while (!limitEntered) { Console.WriteLine("Enter limit that specifies how many boundaries to find before saying that triarc doesn't exist"); Console.WriteLine("0 for short default limit, 1 for medium default, 2 for long default"); limitEntered = int.TryParse(Console.ReadLine(), out limit); if (limit == 0) { limit = 100000; } if (limit == 1) { limit = 1000000; } if (limit == 2) { limit = 10000000; } } Triarc.Do_nnn1_TriarcsExist(ReadFaces(), limit); } break; #endregion case 'b': #region biarc nn { Console.WriteLine("Output will be in file (n,n)BiarcsWithFaces[...]"); int limit = 0; bool limitEntered = false; while (!limitEntered) { Console.WriteLine("Enter limit that specifies how many boundaries to find before saying that triarc doesn't exist"); Console.WriteLine("0 for short default limit, 1 for medium default, 2 for long default"); limitEntered = int.TryParse(Console.ReadLine(), out limit); if (limit == 0) { limit = 100000; } if (limit == 1) { limit = 1000000; } if (limit == 2) { limit = 10000000; } } Triarc.DonnBiarcsExist(ReadFaces(), limit); } break; #endregion case 'g': #region from boundary { Console.WriteLine("Enter boundary se binary number"); string boundaryString = Console.ReadLine(); long boundary = Convert.ToInt64(boundaryString, 2); if (Triarc.DoesGeneralBoundaryExistAndConstruct(boundary, ReadFaces())) { Console.WriteLine("Exists"); } else { Console.WriteLine("Doesn't exist"); } } #endregion break; case 'q': #region QUIT { end = true; continue; } #endregion default: Console.WriteLine("Unvalid key pressed"); break; } Console.ReadKey(); } }
static void Main(string[] args) { try { var ca = new ConsoleArguments(args); if (ca.Limit > 0) { Global.Limit = ca.Limit; } Global.TaskCount = ca.ThreadCount; Global.Count3Connectivity = ca.Count3Connectivity || ca.ExportAsAll; Global.ExportAsGraphViz = ca.ExportAsGraphViz || ca.ExportAsAll; Global.ExportAsTutteSageScript = ca.ExportAsTutteSageScript || ca.ExportAsAll; Global.ExportFaces = ca.ExportFaces || ca.ExportAsAll; Global.ExportAsSequence = !ca.ExportAsSequence || ca.ExportAsAll; Global.ExportAsStandardGraph = !ca.ExportAsStandardGraph || ca.ExportAsAll; ca.Validate(); if (ca.GUI) { GUI(); } else if (ca.Help) { Help(); } else if (ca.Triarc) { if (!Triarc.FindAndBuildTriarc(ca.TriarcX, ca.TriarcY, ca.TriarcZ, ca.faces)) { Console.WriteLine("Doesn't exist"); } } else if (ca.Arc) { if (!Triarc.DoesGeneralBoundaryExistAndConstruct(ca.ArcBoundary, ca.faces)) { Console.WriteLine("Doesn't exist"); } } else if (ca.NeutralSequence) { var ns = new NeutralSequenceHelpingGraphs(ca.faces); ns.Find(); } else if (ca.AllNeutralSequences) { #region AllNeutralSequences var sw = new StreamWriter("table.txt"); for (int j = 7; j < 18; j++) { Console.WriteLine("................................"); Console.WriteLine(j); Console.WriteLine("................................"); Console.WriteLine(); string firstLine = j.ToString(); Func <List <int>, string> toFirst = ks => "(i): " + string.Join <int>(",", ks); string secondLine = ""; Func <List <int>, string> toSecond = ksMinus => "(ii): " + string.Join <int>(",", ksMinus); string thirdLine = ""; Func <string, string> toThird = ab => "AB : " + ab; string fourthLine = ""; Func <string, string> toFourth = ab => "CD : " + ab; string zerothLine = j.ToString(); Func <bool, string> toZeroth = found => found ? "Nalezeno" : "Nenalezeno"; Func <string, string> join = line => line + " & "; for (int i = 3; i <= 5; i++) { zerothLine = join(zerothLine); firstLine = join(firstLine); secondLine = join(secondLine); thirdLine = join(thirdLine); fourthLine = join(fourthLine); var fc = new List <int> { i, j }; var ns = new NeutralSequenceHelpingGraphs(fc) { slow = true }; ns.Find(); if (ns.found) { zerothLine += @"\cellcolor{lightgray}"; firstLine += @"\cellcolor{lightgray}"; secondLine += @"\cellcolor{lightgray}"; thirdLine += @"\cellcolor{lightgray}"; fourthLine += @"\cellcolor{lightgray}"; } zerothLine += toZeroth(ns.found); firstLine += toFirst(ns.ks); secondLine += toSecond(ns.ksMinusOne); thirdLine += toThird(ns.AString); fourthLine += toFourth(ns.CDString); } // sw.WriteLine(zerothLine + "\\\\"); sw.WriteLine(firstLine + "\\\\"); sw.WriteLine(secondLine + "\\\\"); sw.WriteLine(thirdLine + "\\\\"); sw.WriteLine(fourthLine + "\\\\" + "\\hline"); sw.WriteLine(); } sw.Close(); #endregion } else { Help(); } } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } Console.ReadKey(); }
public NeutralSequenceHelpingGraphs(List <int> fs) { this.FaceSizes = fs; path = Triarc.FacesToString(fs) + "\\"; }