public static void Go() { using (var graphEnumerator = new GraphEnumerator(WinnersFile, 2, MaxVertices)) { if (TreesOnly) { graphEnumerator.FileRoot = @"C:\Users\landon\Google Drive\research\Graph6\trees\trees"; } else { graphEnumerator.FileRoot = @"C:\Users\landon\Google Drive\research\Graph6\graph"; } graphEnumerator.DoNotUsePreviousWinners = true; foreach (var gg in graphEnumerator.EnumerateGraph6File(Filter, null)) { System.Console.Write("checking " + gg.ToGraph6() + "... "); var weightings = EnumerateWeightings(gg).ToList(); var winners = new List <Choosability.Graph>(); foreach (var g in weightings) { var mind = new Choosability.FixerBreaker.KnowledgeEngine.Slim.Super.SuperSlimMind(g, false, FixerBreakerSwapMode.SingleSwap); mind.MaxPot = int.MaxValue; mind.OnlySuperabundantBoards = true; mind.ExtraPsi = ExtraPsi; mind.OnlyConsiderNearlyColorableBoards = NearColorings; var template = new Template(g.VertexWeight); var win = mind.Analyze(template, null); if (win) { winners.Add(g); } } var globalWinners = winners.Where(w => SubsetEqualSpecial(weightings.Where(aa => w.VertexWeight.Zip(aa.VertexWeight, (x, y) => x <= y).All(b => b)).ToList(), winners)).ToList(); globalWinners = globalWinners.Where(w => IntersectionCountSpecial(weightings.Where(aa => w.VertexWeight.Zip(aa.VertexWeight, (x, y) => x >= y).All(b => b)).ToList(), globalWinners) == 1).ToList(); if (globalWinners.Count > 0) { System.Console.ForegroundColor = ConsoleColor.Green; System.Console.WriteLine(" fixer wins"); System.Console.ForegroundColor = ConsoleColor.White; foreach (var ww in globalWinners) { graphEnumerator.AddWinner(ww); } } else { System.Console.ForegroundColor = ConsoleColor.Red; System.Console.WriteLine(" breaker wins"); System.Console.ForegroundColor = ConsoleColor.White; } } } }
static void Eliminate(string path) { var eliminatedPath = path + ".triangle_eliminated.txt"; File.Delete(eliminatedPath); foreach (var g in GraphEnumerator.EnumerateGraphFile(path)) { var ones = g.VertexWeight.IndicesWhere(w => w == 1).ToList(); if (ones.Count == 2 && g[ones[0], ones[1]]) { var n1 = g.Neighbors[ones[0]]; var n2 = g.Neighbors[ones[1]]; var common = n1.Intersection(n2); if (common.Any(v => g.Degree(v) == 2)) { continue; } } g.AppendWeightStringToFile(eliminatedPath); } }
public static bool WeightCondition(Graph self, Graph A, int selfV, int av) { if (Not) { return(GraphEnumerator.WeightConditionUp(self, A, selfV, av)); } return(GraphEnumerator.WeightConditionDown(self, A, selfV, av)); }
static void Eliminate(string path) { var eliminatedPath = path + ".nosink.txt"; File.Delete(eliminatedPath); foreach (var g in GraphEnumerator.EnumerateGraphFile(path).EliminateSinks()) { g.AppendWeightStringToFile(eliminatedPath); } }
public static void Go() { using (var graphEnumerator = new GraphEnumerator(WinnersFile, 2, MaxVertices)) { if (TreesOnly) { graphEnumerator.FileRoot = @"C:\Users\landon\Google Drive\research\Graph6\trees\trees"; } else if (TreesOrTreesPlusEdgeOnly) { graphEnumerator.FileRoot = @"C:\Users\landon\Google Drive\research\Graph6\degree5treesplusedge\geng"; } else if (Planar) { graphEnumerator.FileRoot = @"C:\Users\landon\Google Drive\research\Graph6\planar\planar_conn."; } else { graphEnumerator.FileRoot = @"C:\Users\landon\Google Drive\research\Graph6\graph"; } foreach (var g in graphEnumerator.EnumerateGraph6File(Filter, EnumerateWeightings)) { System.Console.Write("checking " + g.ToGraph6() + " with degrees [" + string.Join(",", g.VertexWeight) + "] ..."); var mind = new Choosability.FixerBreaker.KnowledgeEngine.Slim.Super.SuperSlimMind(g, false, SwapMode); mind.MaxPot = Delta; mind.OnlyConsiderNearlyColorableBoards = NearColorings; var template = new Template(g.VertexWeight.Select((ambientDegree, v) => Delta - (ambientDegree - g.Degree(v))).ToList()); var win = mind.Analyze(template, null); if (win) { System.Console.ForegroundColor = ConsoleColor.Blue; System.Console.WriteLine(" fixer wins"); System.Console.ForegroundColor = ConsoleColor.White; graphEnumerator.AddWinner(g); _wonWeightings.Add(g.VertexWeight); if (MakeWebPage) { MakePictures.MakeWebpage(WinnersFile, Path.Combine(WebpageRoot, Path.GetFileNameWithoutExtension(WinnersFile))); } } else { System.Console.ForegroundColor = ConsoleColor.Red; System.Console.WriteLine(" breaker wins"); System.Console.ForegroundColor = ConsoleColor.White; } } } }
public static void Go() { var gn = new GraphEnumerator(OutputFile, MinN, MaxN, false); gn.FileRoot = GraphFileRoot; foreach (var g in gn.EnumerateGraph6File()) { if (IsUnitDistance(g)) { gn.AddWinner(g); } } }
static void Eliminate(string path) { var eliminatedPath = path + ".not.eliminated.txt"; File.Delete(eliminatedPath); var graphs = GraphEnumerator.EnumerateGraphFile(path).ToList(); var excluded = graphs.SelectMany(g => OneStepEliminators(g)).ToList(); foreach (var gg in graphs.Where(g => excluded.All(h => !Graph.Isomorphic(h, g)))) { WriteGraph(gg, eliminatedPath); } }
public static void Go() { using (var graphEnumerator = new GraphEnumerator("superabundant near coloring original fixable test.txt", 2, 20)) { graphEnumerator.FileRoot = @"C:\Users\landon\Google Drive\research\Graph6\graph"; foreach (var g in graphEnumerator.EnumerateGraph6File(g => true, EnumerateWeightings)) { System.Console.Write("checking " + g.ToGraph6() + " with degrees [" + string.Join(",", g.VertexWeight) + "] ..."); var mind = new Choosability.FixerBreaker.KnowledgeEngine.Slim.Super.SuperSlimMind(g, false, FixerBreakerSwapMode.SingleSwap); mind.MaxPot = Delta; mind.OnlySuperabundantBoards = true; mind.OnlyConsiderNearlyColorableBoards = true; var weakMind = new Choosability.FixerBreaker.KnowledgeEngine.Slim.Super.SuperSlimMind(g, false, FixerBreakerSwapMode.Original); weakMind.MaxPot = Delta; weakMind.OnlySuperabundantBoards = true; weakMind.OnlyConsiderNearlyColorableBoards = true; var template = new Template(g.VertexWeight); var win = mind.Analyze(template, null); var winWeak = weakMind.Analyze(template, null); if (win != winWeak) { System.Console.ForegroundColor = ConsoleColor.Red; System.Console.WriteLine(" weakly is weaker"); System.Console.ForegroundColor = ConsoleColor.White; graphEnumerator.AddWinner(g); } else { if (win) { System.Console.ForegroundColor = ConsoleColor.Blue; } else { System.Console.ForegroundColor = ConsoleColor.Green; } System.Console.ForegroundColor = ConsoleColor.White; } } } }
public static void Go() { var gn = new GraphEnumerator(OutputFile, MinN, MaxN, false); gn.FileRoot = GraphFileRoot; foreach (var G in gn.EnumerateGraph6File()) { var Q = G.LineGraph.Value; // var Q = G; var gi = GammaInfinity(Q, R); var gim = GammaInfinityMonotone(Q, R); if (gim - gi > 0) { System.Console.WriteLine(string.Format("{0} - {1} = {2}, {3}", gim, gi, gim - gi, G.ToGraph6())); System.Console.ReadKey(); } } }
static void DoIt(string name, int bound) { var file = name + ".txt"; Clear(file); using (var graphEnumerator = new GraphEnumerator(file, Min, Max, true)) { graphEnumerator.FileRoot = @"C:\Users\landon\Google Drive\research\Graph6\graph"; graphEnumerator.WeightCondition = (_, __, ___, ____) => true; graphEnumerator.OnlyExcludeBySpanningSubgraphs = false; foreach (var g in graphEnumerator.EnumerateGraph6File(null, Secondary, false)) { if (PotentialAtMost(g, bound)) { graphEnumerator.AddWinner(g); System.Console.WriteLine(bound + " winner : " + g.ToGraph6()); } } } }
public static void Go() { int k = 5; using (var graphEnumerator = new GraphEnumerator(string.Format("mic{0}b.txt", k), k, k, false)) { graphEnumerator.FileRoot = @"C:\Users\landon\Google Drive\research\Graph6\VertexCritical\chi"; foreach (var g in graphEnumerator.EnumerateGraph6File()) { var micG = g.Mic(); var diff = micG - (g.N + k - 4); //System.Console.WriteLine(g.ToGraph6() + " :: " + diff); if (diff < 0) { graphEnumerator.AddWinner(g); System.Console.WriteLine(diff); } } } }
static void Eliminate(string path) { var eliminatedPath = path + ".eliminated.txt"; File.Delete(eliminatedPath); var P4 = Choosability.Graphs.P(4); foreach (var g in GraphEnumerator.EnumerateGraphFile(path)) { P4.VertexWeight = new List <int>() { 0, 0, 0, 0 }; if (g.Contains(P4, true, WeightConditionEqualAndDegreeTwoInternal)) { continue; } P4.VertexWeight = new List <int>() { 1, 0, 0, 0 }; if (g.Contains(P4, true, WeightConditionEqualAndDegreeTwoInternal)) { continue; } P4.VertexWeight = new List <int>() { 1, 0, 0, 1 }; if (g.Contains(P4, true, WeightConditionEqualAndDegreeTwoInternal)) { continue; } WriteGraph(g, eliminatedPath); } }
public static void Go() { int total = 0; int skipped = 0; var forbidden = GraphEnumerator.EnumerateGraphFile(ForbiddenPath).ToList(); var gn = new GraphEnumerator(OutputFile, MinN, MaxN, false); gn.FileRoot = GraphFileRoot; foreach (var g in gn.EnumerateGraph6File()) { total++; if (forbidden.Any(h => g.Contains(h, Induced))) { skipped++; continue; } gn.AddWinner(g); } System.Console.WriteLine(100 * skipped / total + "% skipped"); }
public GraphPictureMaker(string graphFile) : this(GraphEnumerator.EnumerateGraphFile(graphFile)) { }
public static void Go() { using (var graphIO = new GraphEnumerator(WinnersFile, MinVertices, MaxVertices)) { graphIO.FileRoot = @"C:\Users\landon\Google Drive\research\Graph6\graph"; foreach (var g in graphIO.EnumerateGraph6File()) { if (MaxIndependenceNumber < int.MaxValue) { if (g.EnumerateMaximalIndependentSets().Any(mis => mis.Count > MaxIndependenceNumber)) { continue; } } if (MaxDegree < int.MaxValue && g.MaxDegree > MaxDegree) { continue; } if (AT) { System.Console.Write("checking " + g.ToGraph6() + "..."); if (!g.IsOnlineFGChoosable(v => g.Degree(v) - 1, v => 1)) { System.Console.WriteLine(" not paintable"); } else { var result = HasFOrientation(g, v => g.Degree(v) - 1, true); if (result != null) { graphIO.AddWinner(g, result.Graph); System.Console.WriteLine(string.Format(" is d_1-AT")); } else { System.Console.WriteLine(" not AT"); } } } else if (Offline) { if (g.EnumerateMaximalIndependentSets().Any(I => I.Count > 2)) { continue; } System.Console.Write("checking " + g.ToGraph6() + "..."); List <List <int> > badAssignment; var bg = new BitGraph_long(g.GetEdgeWeights()); System.Console.Write("checking " + g.ToGraph6() + "..."); if (bg.IsFChoosable(v => bg.Degree(v) - 1, out badAssignment)) { graphIO.AddWinner(g); System.Console.WriteLine(string.Format(" is {0}-fold d_1-choosable", Fold)); } else { System.Console.WriteLine(" not choosable"); } } else { if (!DiamondFreeOnly || !g.ContainsInduced(Choosability.Graphs.Diamond)) { System.Console.Write("checking " + g.ToGraph6() + "..."); if (g.IsOnlineFGChoosable(v => Fold * g.Degree(v) - 1, v => Fold)) { graphIO.AddWinner(g); System.Console.WriteLine(string.Format(" is {0}-fold d_1-paintable", Fold)); } else { System.Console.WriteLine(" not paintable"); } } else { System.Console.WriteLine("skipping due to diamond " + g.ToGraph6()); } } } } }
public static void Go() { using (var graphEnumerator = new GraphEnumerator(WinnersFile, MinVertices, MaxVertices, false)) { graphEnumerator.FileRoot = @"C:\Users\landon\Google Drive\research\Graph6\graph"; graphEnumerator.WeightCondition = WeightCondition; graphEnumerator.OnlyExcludeBySpanningSubgraphs = false; foreach (var g in graphEnumerator.EnumerateGraph6File(Filter, EnumerateWeightings, induced: true)) { if (MaxIndependenceNumber < int.MaxValue) { if (g.EnumerateMaximalIndependentSets().Any(mis => mis.Count > MaxIndependenceNumber)) { continue; } } if (g.MaxDegree > MaxDegree) { continue; } if (g.MinDegree < MinDegree) { continue; } if (Mic) { System.Console.Write("checking " + g.ToGraph6() + " with weights [" + string.Join(",", g.VertexWeight) + "] ..."); var micScore = g.Vertices.Sum(v => g.VertexWeight[v] + 1); if (g.Mic() >= micScore) { graphEnumerator.AddWinner(g); System.Console.WriteLine(string.Format(" is f-KP")); } else { System.Console.WriteLine(" not f-mic'able"); } } else if (AT) { System.Console.Write("checking " + g.ToGraph6() + " with weights [" + string.Join(",", g.VertexWeight) + "] ..."); if (!Not) { if (!g.IsOnlineFGChoosable(v => g.Degree(v) - g.VertexWeight[v], v => 1)) { System.Console.WriteLine(" not paintable"); } else { var result = HasFOrientation(g, v => g.Degree(v) - g.VertexWeight[v], true); if (result != null) { if (OddAT) { if (Math.Abs(result.Even - result.Odd) % 2 == 1) { graphEnumerator.AddWinner(g, result.Graph); System.Console.WriteLine(string.Format(" is odd f-AT")); } else { System.Console.WriteLine(string.Format(" not odd f-AT")); } } else { graphEnumerator.AddWinner(g, result.Graph); System.Console.WriteLine(string.Format(" is f-AT")); } } else { System.Console.WriteLine(" not AT"); } } } else { var good = !g.IsOnlineFGChoosable(v => g.Degree(v) - g.VertexWeight[v], v => 1); var result = HasFOrientation(g, v => g.Degree(v) - g.VertexWeight[v], true); good |= result == null || OddAT && Math.Abs(result.Even - result.Odd) % 2 == 0; if (good) { graphEnumerator.AddWinner(g); System.Console.WriteLine(string.Format(" not f-AT")); } else { System.Console.WriteLine(" is AT"); } } } else if (Offline) { List <List <int> > badAssignment; var bg = new BitGraph_long(g.GetEdgeWeights()); System.Console.Write("checking " + " with weights [" + string.Join(",", g.VertexWeight) + "] ..."); if (bg.IsFChoosable(v => bg.Degree(v) - g.VertexWeight[v], out badAssignment)) { graphEnumerator.AddWinner(g); System.Console.WriteLine(string.Format(" is {0}-fold f-choosable", Fold)); } else { System.Console.WriteLine(" not choosable"); } } else { System.Console.Write("checking " + " with weights [" + string.Join(",", g.VertexWeight) + "] ..."); if (!Not) { if (g.IsOnlineFGChoosable(v => Fold * g.Degree(v) - g.VertexWeight[v], v => Fold)) { graphEnumerator.AddWinner(g); System.Console.WriteLine(string.Format(" is {0}-fold f-paintable", Fold)); } else { System.Console.WriteLine(" not paintable"); } } else { if (!g.IsOnlineFGChoosable(v => Fold * g.Degree(v) - g.VertexWeight[v], v => Fold)) { graphEnumerator.AddWinner(g); System.Console.WriteLine(string.Format(" is not {0}-fold f-paintable", Fold)); } else { System.Console.WriteLine(" paintable"); } } } } } if (Not) { EliminateDoubleEdgeNotSubdivisions.Go(WinnersFile, AT); } else { EliminiteDoubleEdgeSubdivisions.Go(WinnersFile); } }
public static void Go() { using (var swbest = new StreamWriter(WinnersFile + ".best.txt")) using (var swg = new StreamWriter(WinnersFile + ".txt")) using (var swb = new StreamWriter(WinnersFile + ".bad" + ".txt")) { swbest.AutoFlush = true; swg.AutoFlush = true; swb.AutoFlush = true; using (var graphIO = new GraphEnumerator(WinnersFile + ".blah", MinVertices, MaxVertices)) { // graphIO.FileRoot = @"C:\Users\landon\Google Drive\research\Graph6\graph"; // graphIO.FileRoot = @"C:\Users\landon\Google Drive\research\Graph6\trianglefree\nopendant\geng"; graphIO.FileRoot = @"C:\Users\landon\Google Drive\research\Graph6\nopendant\geng"; var lastg6 = ""; var lastSkip = ""; var skipCount = 0; foreach (var g in graphIO.EnumerateGraph6File(null, EnumerateEdgeSubsets)) { //if (MaxDegree < int.MaxValue && g.MaxDegree > MaxDegree) //{ // ReportSkip("D", ref skipCount, ref lastSkip); // continue; //} //if (g.IsCliqueNumberAtLeast(3)) //{ // ReportSkip("T", ref skipCount, ref lastSkip); // continue; //} if (g.IsDisconnected(g.EdgeWeightsWithMultiplicity, 1)) { ReportSkip("D", ref skipCount, ref lastSkip); continue; } if (g.IsTree(g.EdgeWeightsWithMultiplicity, 1)) { ReportSkip("T", ref skipCount, ref lastSkip); continue; } if (g.IsTwoColorable()) { ReportSkip("2", ref skipCount, ref lastSkip); continue; } if (g.IsMicKP(g.EdgeWeightsWithMultiplicity, 1)) { ReportSkip("M", ref skipCount, ref lastSkip); continue; } //if (!g.IsTwoColorable(g.EdgeWeightsWithMultiplicity, 1)) //{ // ReportSkip("B", ref skipCount, ref lastSkip); // continue; //} if (g.HasMonochromaticOddHoleOrCliqueCycle(g.EdgeWeightsWithMultiplicity, 1)) { ReportSkip("Z", ref skipCount, ref lastSkip); continue; } //if (!AllCyclesHaveFullIndependentset(g)) //{ // ReportSkip("H", ref skipCount, ref lastSkip); // continue; //} //if (!AllHamiltonHaversHaveFullIndependentset(g)) //{ // ReportSkip("HH", ref skipCount, ref lastSkip); // continue; //} if (lastSkip != "") { System.Console.WriteLine(); } lastSkip = ""; skipCount = 0; var g6 = g.ToGraph6(); if (g6 != lastg6) { if (!string.IsNullOrEmpty(lastg6)) { var gain = BestKP[lastg6] - Ng6[lastg6]; var sgain = BestKP[lastg6] - Micg6[lastg6]; swbest.WriteLine(lastg6 + " " + BestKP[lastg6] + " N: " + Ng6[lastg6] + " E: " + Eg6[lastg6] + " gain: " + gain + " micgain: " + sgain); } System.Console.WriteLine("checking " + g6); BestKP[g6] = 0; Ng6[g6] = g.N; Eg6[g6] = g.E; Micg6[g6] = g.Mic(); lastg6 = g6; } System.Console.ForegroundColor = ConsoleColor.DarkGray; System.Console.Write(g.EdgeWeightsWithMultiplicity.ToSetString() + "... "); System.Console.ForegroundColor = ConsoleColor.White; var symmetricEdges = g.EdgeWeightsWithMultiplicity.IndicesWhere(w => w == 2).ToList(); List <int> badSubgraph; var badOrientation = g.CheckKernelPerfectForAllOrientations(symmetricEdges, out badSubgraph); if (badOrientation != null) { var w = new List <int>(); int k = 0; for (int i = 0; i < g.N; i++) { for (int j = i + 1; j < g.N; j++) { if (g[i, j]) { if (badOrientation[j].Contains(i)) { w.Add(-1); } else { w.Add(1); } } else { w.Add(0); } k++; } } var gg = GraphsCore.GraphIO.GraphFromEdgeWeightString(string.Join(" ", w)); foreach (var i in symmetricEdges) { gg.Edges[i].Multiplicity = 2; } var webgraph = GraphsCore.CompactSerializer.Serialize(gg); System.Console.ForegroundColor = ConsoleColor.Red; System.Console.WriteLine("bad"); System.Console.ForegroundColor = ConsoleColor.White; if (badSubgraph.Count == g.N) { swb.WriteLine(webgraph); } } else { _winnerSets.Add(symmetricEdges); var gg = GraphsCore.GraphIO.GraphFromGraph6(g.ToGraph6()); foreach (var i in symmetricEdges) { gg.Edges[i].Multiplicity = 2; } var webgraph = GraphsCore.CompactSerializer.Serialize(gg); System.Console.ForegroundColor = ConsoleColor.Green; System.Console.WriteLine("good"); System.Console.ForegroundColor = ConsoleColor.White; swg.WriteLine(webgraph); BestKP[g6] = Math.Max(BestKP[g6], g.E - symmetricEdges.Count); } } if (!string.IsNullOrEmpty(lastg6)) { var gain = BestKP[lastg6] - Ng6[lastg6]; var sgain = BestKP[lastg6] - Micg6[lastg6]; swbest.WriteLine(lastg6 + " " + BestKP[lastg6] + " N: " + Ng6[lastg6] + " E: " + Eg6[lastg6] + " gain: " + gain + " micgain: " + sgain); } } } }