예제 #1
0
        public I_Network Generate(int node_num, List <string[]> raw_edge_list, NetworkEnum network_enum, int network_seed)
        {
            var node_list = new List <I_Node>();
            var edge_list = new List <I_Edge>();

            if (node_num == 0 || raw_edge_list == null)
            {
                return(null);
            }

            //node
            for (int i = 0; i < node_num; i++)
            {
                node_list.Add(new Node(i));
            }

            //edge
            for (int i = 0; i < raw_edge_list.Count; i++)
            {
                var edge = new Edge(i, int.Parse(raw_edge_list[i][1]), int.Parse(raw_edge_list[i][2]));
                node_list[edge.SourceNodeID].AttachEdgeIDList.Add(edge.EdgeID);
                node_list[edge.SourceNodeID].NeighborNodeIDList.Add(edge.TargetNodeID);
                node_list[edge.TargetNodeID].AttachEdgeIDList.Add(edge.EdgeID);
                node_list[edge.TargetNodeID].NeighborNodeIDList.Add(edge.SourceNodeID);
                edge_list.Add(edge);
            }

            return(new BaseNetwork(node_list, edge_list, network_enum, network_seed));
        }
예제 #2
0
 public BaseNetwork(List <I_Node> node_list, List <I_Edge> edge_list, NetworkEnum network_enum, int seed)
 {
     this.NodeList      = node_list;
     this.EdgeList      = edge_list;
     this.MyNetworkEnum = network_enum;
     this.NetworkSeed   = seed;
 }
        void MakeFile(NetworkEnum n_enum, int node_num, int n_seed, AlgoEnum a_enum)
        {
            var    di           = new DirectoryInfo(this.OutputFolderPath);
            string condition    = "_nenum." + n_enum.ToString() + "_node." + node_num.ToString() + "_aenum." + a_enum.ToString();
            var    condi_folder = di + "\\" + condition;

            OutputLog.SafeCreateDirectory(condi_folder);
            this.OutputRoundFilePath = OutputLog.SafeCreateCSV(new DirectoryInfo(condi_folder), "RoundOpinion" + condition + "_nseed." + n_seed.ToString());
        }
예제 #4
0
        /// <summary>
        /// Get current balance of provided address.
        /// </summary>
        /// <responseCode>200 Ok</responseCode>
        public async Task <Response <IEnumerable <AddressBalance> > > GetAddressBalanceAsync(
            NetworkEnum network,
            string address)
        {
            var path = HttpHelper.UrlCombine(
                network.GetValue(),
                PathConstants.Utxos,
                address);

            return(await GetRequest.GetAsync <IEnumerable <AddressBalance> >(path));
        }
예제 #5
0
        internal static string FetchTextFromBitmap(Bitmap bitmap, NetworkEnum networkEnum)
        {
            string text = string.Empty;

            try
            {
                Bitmap[] bitmaps = FetchConnectedComponentLabels(bitmap);
                if (bitmaps.Length > 0)
                {
                    int[] predictions = AppData.networks[(int)networkEnum].GetPredictionFromBitmaps(bitmaps);
                    switch (networkEnum)
                    {
                    case NetworkEnum.Maps:
                    case NetworkEnum.Heroes:
                        text = string.Join("", predictions.Select(x => (char)((int)'A' + x)).ToArray());
                        break;

                    case NetworkEnum.Ratings:
                    case NetworkEnum.Stats:
                        text = string.Join("", predictions.Select(x => x.ToString()).ToArray());
                        break;

                    case NetworkEnum.Players:
                        foreach (int prediction in predictions)
                        {
                            if (((int)'A' + prediction - 9) < (int)'A')
                            {
                                text += (prediction + 1).ToString();
                            }
                            else
                            {
                                text += (char)((int)'A' + prediction - 9);
                            }
                        }
                        break;
                    }
                }
                foreach (Bitmap bmp in bitmaps)
                {
                    bmp.Dispose();
                }
            }
            catch (Exception e)
            {
                Functions.DebugMessage("BitmapManipulation.FetchTextFromBitmap() error: " + e);
            }
            return(text);
        }
예제 #6
0
 private Network(NetworkEnum network)
 {
     _network = network;
 }
예제 #7
0
        internal static string ProcessFrame(Bitmap frame, Rectangle rect, bool contrastFirst = false, short radius = 110, NetworkEnum network = NetworkEnum.Maps, bool invertColors = false, byte red = 255, byte green = 255, byte blue = 255, bool fillOutside = true, bool limeToWhite = false)
        {
            string output = string.Empty;

            try
            {
                using (Bitmap cropped = CropImage(frame, rect))
                {
                    using (Bitmap cloned = new Bitmap(rect.Width, rect.Height, PixelFormat.Format24bppRgb))
                    {
                        using (Graphics g = Graphics.FromImage(cloned))
                        {
                            g.DrawImage(cropped, new Rectangle(0, 0, rect.Width, rect.Height));
                        }
                        if (contrastFirst)
                        {
                            AdjustContrast(cloned, 255f, invertColors, limeToWhite);
                            AdjustColors(cloned, radius, red, green, blue, fillOutside);
                        }
                        else
                        {
                            AdjustColors(cloned, radius, red, green, blue, fillOutside);
                            AdjustContrast(cloned, 255f, invertColors, limeToWhite);
                        }

                        output = FetchTextFromBitmap(cloned, network);
                    }
                }
            }
            catch (Exception e) { Console.WriteLine($"BitmapToText error: {e}"); }
            return(output);
        }