public void AddWinner(Graph g, Graph output = null) { PreviousWinners.Add(g); if (output != null) { output.VertexWeight = g.VertexWeight; } output = output ?? g; output.AppendWeightStringToFile(WinnersFile); }
public IEnumerable <Graph> EnumerateGraph6File(Func <Graph, bool> filter = null, Func <Graph, IEnumerable <Graph> > secondaryEnumerator = null, bool induced = false) { var min = MinVertices; string lastGraph6 = null; var foundPreviousLast = true; if (Last != null) { min = Last.N; lastGraph6 = Last.GetEdgeWeights().ToGraph6(); foundPreviousLast = false; } for (int N = min; N <= MaxVertices; N++) { System.Console.WriteLine(); System.Console.ForegroundColor = ConsoleColor.DarkCyan; System.Console.WriteLine("Checking " + N + " vertex graphs..."); System.Console.ForegroundColor = ConsoleColor.White; var file = FileRoot + N + (RingSize > 0 ? "_" + RingSize : "") + ".g6"; if (!File.Exists(file)) { System.Console.WriteLine(file + " does not exist, skipping."); continue; } using (var sr = new StreamReader(file)) { while (true) { var line = sr.ReadLine(); if (line == null) { goto next; } if (!foundPreviousLast) { if (line.StartsWith(lastGraph6)) { foundPreviousLast = true; } continue; } var ew = line.GetEdgeWeights(); var g = new Graph(ew); if (filter == null || filter(g)) { if (secondaryEnumerator != null) { foreach (var gg in secondaryEnumerator(g)) { if (PreviousWinners.All(h => h.N != gg.N && OnlyExcludeBySpanningSubgraphs || !gg.Contains(h, induced, WeightCondition))) { yield return(gg); } else { if (gg.VertexWeight != null) { System.Console.WriteLine("skipping supergraph " + gg.ToGraph6() + " with degrees [" + string.Join(",", gg.VertexWeight) + "]"); } else { System.Console.WriteLine("skipping supergraph " + gg.ToGraph6()); } } } } else { if (DoNotUsePreviousWinners || PreviousWinners.All(h => !g.ContainsInduced(h))) { yield return(g); } else { System.Console.WriteLine("skipping supergraph " + g.ToGraph6()); } } } } } next :; } }