public void TestGraphCreator_OneProjectOneExpert()
        {
            //arrange
            var x = new ExpertProjectInformation()
            {
                ExpertCount         = 1,
                ProjectCount        = 1,
                SkillCount          = 1,
                ProjectRequirements = new List <List <int> >()
                {
                    new List <int>()
                    {
                        1
                    }
                },
                ExpertSkills = new List <List <int> >()
                {
                    new List <int>()
                    {
                        1
                    }
                }
            };

            //act
            var g = GraphConverter.ExpertProjectInformationToGraph(x);

            //assert

            //GraphExport ge = new GraphExport();
            //ge.Export(g);
        }
Exemple #2
0
        public void BigGraphWithNoCycle()
        {
            List <string> input = new List <string>()
            {
                "10",
                "0 1 0 0 0 0 0 0 0 0",
                "1 0 1 0 0 0 0 0 0 0",
                "0 1 0 1 1 1 0 0 0 0",
                "0 0 1 0 0 0 1 1 0 0",
                "0 0 1 0 0 0 0 0 1 0",
                "0 0 1 0 0 0 0 0 0 1",
                "0 0 0 1 0 0 0 0 0 0",
                "0 0 0 1 0 0 0 0 0 0",
                "0 0 0 0 1 0 0 0 0 0",
                "0 0 0 0 0 1 0 0 0 0"
            };
            List <int> vertexesInCycle = DfsFinder.FindCycle(GraphConverter.CreateGraph(input));
            string     result          = "";

            if (vertexesInCycle == null)
            {
                result = "A";
            }
            else
            {
                result = "N\r\n";
                vertexesInCycle.ForEach(vertex => result += vertex);
            }
            Assert.AreEqual("A", result);
        }
        private void calculateAllButton_Click(object sender, EventArgs e)
        {
            if (_controlZgcList[(int)numericUpDownGraphNo.Value - 1].GraphPane.CurveList.Count == 0)
            {
                return;
            }

            var list = GraphConverter.GetPointPairListFromCurve(_controlZgcList[(int)numericUpDownGraphNo.Value - 1].GraphPane.CurveList[0]);

            minTextBox.Text = $"{Analyser.GetMinOnRange(list)}";
            maxTextBox.Text = $"{Analyser.GetMaxOnRange(list)}";

            var avrg = Analyser.GetAverageOnRange(list);

            avgTextBox.Text = $"{avrg}";

            var disp = Analyser.GetDispersionOnRange(list, avrg);

            DisperTextBox.Text = $"{disp}";

            stdDevTextBox.Text = $"{Analyser.GetSigmaByDispersion(disp)}";

            var mediumSquare = Analyser.GetMeanSquare(list);

            medSquareTextBox.Text = $"{mediumSquare}";

            AccumM3TextBox.Text = $"{Analyser.GetAsymmetryMoment(list)}";
            rmeTextBox.Text     = $"{Analyser.GetRootMeanSquare(mediumSquare)}";

            kurtosisTextBox.Text = $"{Analyser.GetKurtosis(list)}";

            stationaryTextBox.Text = Analyser.CheckStationary(list) ? "Стационарен" : "Не стационарен";
        }
Exemple #4
0
        public Writer(Encoding encoding)
        {
            this.encoding = encoding;

            keyConverter   = new KeyConverter();
            graphConverter = new GraphConverter(
                type: typeof(T),
                keyConverter: keyConverter);

            serializer = new XmlSerializer(typeof(GraphMLType));
        }
        private void pltRxxButton_Click(object sender, EventArgs e)
        {
            if (_controlZgcList[(int)numericUpDownGraphNo.Value - 1].GraphPane.CurveList.Count == 0)
            {
                return;
            }

            var list = GraphConverter.GetPointPairListFromCurve(_controlZgcList[(int)numericUpDownGraphNo.Value - 1].GraphPane.CurveList[0]);
            var res  = Analyser.GetRxx(list);

            Plotter.Clear(rxxZedGraphControl);
            Plotter.Draw(rxxZedGraphControl, res, "Rxx");
        }
        private void plotDistributionButton_Click(object sender, EventArgs e)
        {
            if (_controlZgcList[(int)numericUpDownGraphNo.Value - 1].GraphPane.CurveList.Count == 0)
            {
                return;
            }

            var list = GraphConverter.GetPointPairListFromCurve(_controlZgcList[(int)numericUpDownGraphNo.Value - 1].GraphPane.CurveList[0]);
            var res  = Analyser.GetDistribution(list);

            Plotter.Clear(distributionZedGraphControl);
            Plotter.Draw(distributionZedGraphControl, res, "Распределение");
        }
Exemple #7
0
        static void Main(string[] args)
        {
            var gl         = new GraphLoader();
            var florentine = gl.LoadMultilayerGraph("../../../Datasets/Florentine/florentine.mpx");

            florentine.ActorNames.ForEach(e => florentine.PrintInfoAboutActor(e));

            var gc            = new GraphConverter();
            var acmTemporal   = gl.LoadTemporalGraph("../../../Datasets/ACM Hypertex 2009/ht09_contact_list.tsv");
            var acmMultilayer = gc.ConvertTemporalToMultilayerGraph(acmTemporal, 5);

            acmMultilayer.ActorNames.ForEach(e => acmMultilayer.PrintInfoAboutActor(e));
        }
        private void spectrePlotButton_Click(object sender, EventArgs e)
        {
            if (_controlZgcList[(int)numericUpDownGraphNo.Value - 1].GraphPane.CurveList.Count == 0)
            {
                return;
            }

            var list = GraphConverter.GetPointPairListFromCurve(_controlZgcList[(int)numericUpDownGraphNo.Value - 1].GraphPane.CurveList[0]);
            var res  = Analyser.GetSpectre(list, norm_checked.Checked);

            res.RemoveRange(list.Count / 2, list.Count - list.Count / 2);
            Plotter.Clear(spectreZedGraphControl);
            Plotter.Draw(spectreZedGraphControl, res, "Spectre");
        }
        private void Fur1DButton_Click(object sender, EventArgs e)
        {
            if (_controlZgcList[(int)numericUpDownGraphNo.Value - 1].GraphPane.CurveList.Count == 0)
            {
                return;
            }

            var list = GraphConverter.GetPointPairListFromCurve(_controlZgcList[(int)numericUpDownGraphNo.Value - 1].GraphPane.CurveList[0]);
            var res  = Analyser.ListToComplex(list);

            res = Analyser.ReverseSpectre(Analyser.GetSpectre(res));

            var newlist = Analyser.ComplexToPointPairList(res);

            Plotter.Clear(spectreZedGraphControl);
            Plotter.Draw(spectreZedGraphControl, newlist, "Reversed Graph");
        }
        public void OneVertexGraph()
        {
            List <string> input = new List <string>()
            {
                "1",
                "0"
            };
            List <int> vertexesInCycle = BfsFinder.FindCycle(GraphConverter.CreateGraph(input));
            string     result          = "";

            if (vertexesInCycle.Count == 0)
            {
                result = "A";
            }
            else
            {
                result = "N\r\n";
                vertexesInCycle.ForEach(vertex => result += vertex);
            }
            Assert.AreEqual("A", result);
        }
Exemple #11
0
        public void BigGraphWithManyCycles()
        {
            List <string> input = new List <string>()
            {
                "10",
                "0 1 0 1 0 0 0 1 0 0",
                "1 0 1 0 0 0 0 0 0 0",
                "0 1 0 1 1 1 0 0 0 0",
                "1 0 1 0 0 0 1 1 0 0",
                "0 0 1 0 0 0 0 0 1 1",
                "0 0 1 0 0 0 0 0 0 1",
                "0 0 0 1 0 0 0 1 0 0",
                "1 0 0 1 0 0 1 0 0 0",
                "0 0 0 0 1 0 0 0 0 0",
                "0 0 0 0 1 1 0 0 0 0"
            };
            List <int> vertexesInCycle = DfsFinder.FindCycle(GraphConverter.CreateGraph(input));
            string     result          = "";

            if (vertexesInCycle == null)
            {
                result = "A";
            }
            else
            {
                result = "N\r\n";
                vertexesInCycle.ForEach(vertex => result += vertex);
            }
            Assert.IsTrue(result.CompareTo("N\r\n1234") == 0 ||
                          result.CompareTo("N\r\n048") == 0 ||
                          result.CompareTo("N\r\n0478") == 0 ||
                          result.CompareTo("N\r\n35610") == 0 ||
                          result.CompareTo("N\r\n478") == 0 ||
                          result.CompareTo("N\r\n123478") == 0 ||
                          result.CompareTo("N\r\n12348") == 0);
        }
        static async Task <int> ExecuteAsync(string path, List <string> sources, bool writeGraphviz, string variantName, bool noVariantName)
        {
            Console.WriteLine("Parsing the file name...");

            if (!path.EndsWith(GraphSerializer.FileExtension, StringComparison.OrdinalIgnoreCase))
            {
                Console.WriteLine($"The serialized graph must have the extension {GraphSerializer.FileExtension}");
                return(1);
            }

            if (!Helper.TryParseFileName(path, out var graphType, out var parsedVariantName, out var solutionName))
            {
                graphType         = null;
                parsedVariantName = null;
                solutionName      = null;
            }

            Console.WriteLine($"  Graph type:    {graphType ?? "(none)"}");
            Console.WriteLine($"  Variant name:  {parsedVariantName ?? "(none)"}");
            Console.WriteLine($"  Solution name: {solutionName ?? "(none)"}");

            if (noVariantName)
            {
                parsedVariantName = null;
                Console.WriteLine("Using no variant name because of command line switch.");
            }

            var actualVariantName = parsedVariantName;

            if (variantName != null)
            {
                actualVariantName = variantName;
                Console.WriteLine($"Using variant name '{variantName}' from command line option.");
            }

            var dir = Path.GetDirectoryName(path);

            if (graphType == RequestGraph.Type)
            {
                var requestGraph = ParseGraph <RequestGraph, RequestNode>(path, RequestGraphSerializer.ReadFromFile);

                Console.WriteLine("Converting the request graph to an operation graph...");
                sources = sources == null || !sources.Any() ? requestGraph.Sources : sources;
                var operationGraph = await GraphConverter.ToOperationGraphAsync(requestGraph, sources);

                var filePath = Path.Combine(dir, Helper.GetGraphFileName(OperationGraph.Type, actualVariantName, solutionName));

                if (writeGraphviz)
                {
                    var gvPath = $"{filePath}.gv";
                    Console.WriteLine($"  Writing {gvPath}...");
                    OperationGraphSerializer.WriteToGraphvizFile(gvPath, operationGraph);
                }

                var jsonGzPath = $"{filePath}{GraphSerializer.FileExtension}";
                Console.WriteLine($"  Writing {jsonGzPath}...");
                OperationGraphSerializer.WriteToFile(jsonGzPath, operationGraph);

                return(0);
            }
            else if (graphType == OperationGraph.Type)
            {
                var operationGraph = ParseGraph <OperationGraph, OperationNode>(path, OperationGraphSerializer.ReadFromFile);

                Console.WriteLine("Converting the operation graph to request graph...");
                var requestGraph = await GraphConverter.ToRequestGraphAsync(operationGraph, sources);

                var filePath = Path.Combine(dir, Helper.GetGraphFileName(RequestGraph.Type, actualVariantName, solutionName));

                if (writeGraphviz)
                {
                    var gvPath = $"{filePath}.gv";
                    Console.WriteLine($"  Writing {gvPath}...");
                    RequestGraphSerializer.WriteToGraphvizFile(gvPath, requestGraph);
                }

                var jsonGzPath = $"{filePath}{GraphSerializer.FileExtension}";
                Console.WriteLine($"  Writing {jsonGzPath}...");
                RequestGraphSerializer.WriteToFile(jsonGzPath, requestGraph);

                return(0);
            }
            else
            {
                Console.WriteLine($"The input graph type '{graphType}' is not supported.");
                return(1);
            }
        }
        public void TestGraphCreator_StandardCase()
        {
            //arrange
            var x = new ExpertProjectInformation()
            {
                ExpertCount         = 2,
                ProjectCount        = 3,
                SkillCount          = 4,
                ProjectRequirements = new List <List <int> >()
                {
                    new List <int>()
                    {
                        1,
                        2,
                        3,
                        4
                    },
                    new List <int>()
                    {
                        1,
                        2,
                        3,
                        4
                    },
                    new List <int>()
                    {
                        1,
                        2,
                        3,
                        4
                    }
                },
                ExpertSkills = new List <List <int> >()
                {
                    new List <int>()
                    {
                        1,
                        1,
                        1,
                        1
                    },
                    new List <int>()
                    {
                        1,
                        1,
                        1,
                        1
                    },
                    new List <int>()
                    {
                        1,
                        1,
                        1,
                        1
                    },
                    new List <int>()
                    {
                        1,
                        1,
                        1,
                        1
                    }
                }
            };

            //act
            var g = GraphConverter.ExpertProjectInformationToGraph(x);

            //assert

            //GraphExport ge = new GraphExport();
            //ge.Export(g);
        }