/// <summary> /// テスト用メインメソッド /// </summary> public static void Main(string[] args) { AdjacencyList graph = GRPReader.ReadGraph(Common.INSTANCE_PATH + @"tree_sample.grp"); int[] result = GraphScanning.CalcBreadth(graph, 0); Console.WriteLine("===result==="); foreach (int node in result) { Console.Write(node + ","); } Console.WriteLine(); }
/// <summary> /// テスト用メインメソッド /// </summary> public static void Main(string[] args) { AdjacencyList graph = GRPReader.ReadGraph(Common.INSTANCE_PATH + @"scc_sample2.grp"); if (!graph.IsDirected) { Common.ErrorExit("StronglyConnectedComponentアルゴリズムは、有向辺グラフにのみ適用できます"); } int[] cluster_array = Calc((DirectedAdjacencyList)graph); foreach (int node in cluster_array) { Console.WriteLine(node); } }
public static void Main(string[] args) { AdjacencyList graph = GRPReader.ReadGraph(Common.INSTANCE_PATH + @"eulerian_sample3.grp"); if (!JudgeEulerian(graph)) { Common.ErrorExit("インスタンスはオイラーグラフである必要があります。"); } int[] result = Calc(graph); Console.WriteLine("===result==="); foreach (int node in result) { Console.Write(node + ","); } Console.WriteLine(); }
// This loads all data resources internal void Load(DataLocationList locations) { // Create collections containers = new List <DataReader>(); images = new Dictionary <int, ImageData>(); imageque = new Queue <ImageData>(); previews = new PreviewManager(); imagesets = new List <MatchingImageSet>(); usedimages = new Dictionary <int, int>(); spritecategories = General.Map.Config.GetThingCategories(); spritetypes = General.Map.Config.GetThingTypes(); // Load texture sets foreach (DefinedImageSet ts in General.Map.ConfigSettings.TextureSets) { imagesets.Add(new MatchingImageSet(ts)); } // Sort the texture sets imagesets.Sort(); // Special textures sets allimages = new AllImageSet(); resourceimages = new List <ResourceImageSet>(); // Go for all locations foreach (DataLocation dl in locations) { DataReader c; try { // Choose container type switch (dl.type) { // GRP file container case DataLocationType.RESOURCE_GRP: c = new GRPReader(dl); break; case DataLocationType.RESOURCE_ART: c = new ARTReader(dl); break; // Directory container //case DataLocationType.RESOURCE_DIRECTORY: //c = new DirectoryReader(dl); //break; // PK3 file container //case DataLocationType.RESOURCE_PK3: //c = new PK3Reader(dl); //break; default: throw new NotImplementedException("Unknown DataLocationType"); } } catch (Exception e) { // Unable to load resource General.ErrorLogger.Add(ErrorType.Error, "Unable to load resources from location \"" + dl.location + "\". Please make sure the location is accessible and not in use by another program. The resources will now be loaded with this location excluded. You may reload the resources to try again.\n" + e.GetType().Name + " when creating data reader: " + e.Message); General.WriteLogLine(e.StackTrace); continue; } // Add container containers.Add(c); resourceimages.Add(c.ImageSet); } // Load stuff LoadPalette(); images = LoadImages(); // Sort things foreach (SpriteCategory tc in spritecategories) { tc.SortIfNeeded(); } // Update the used textures General.Map.Data.UpdateUsedImages(); // Add texture names to texture sets foreach (KeyValuePair <int, ImageData> img in images) { // Add to all sets where it matches foreach (var ms in imagesets) { ms.AddImage(img.Value); } // Add to all allimages.AddImage(img.Value); } // Start background loading StartBackgroundLoader(); // Output info General.WriteLogLine("Loaded " + images.Count + " images, " + spritetypes.Count + " sprite types"); }