Example #1
0
        private static bool CheckIfPathAlwaysExists(UndirectedGraph <int, Edge <int> > g)
        {
            bool pathAlwaysExists = true;

            bool shouldContinue = true;

            foreach (var v1 in g.Vertices)
            {
                if (!shouldContinue)
                {
                    break;
                }
                foreach (var v2 in g.Vertices)
                {
                    bool pathFound = EdmondsAlgorithm.DFSSearch(v1, v2, g, out List <Edge <int> > path);
                    if (!pathFound)
                    {
                        pathAlwaysExists = pathFound;
                        shouldContinue   = false;
                        break;
                    }
                }
            }

            return(pathAlwaysExists);
        }
        public void GetCycleGraph_CountTest_ShouldRetun_10()
        {
            int verticesCount = 10;
            var generator     = new GraphGenerator();
            var g             = generator.GetCycleGraph(verticesCount);

            Assert.AreEqual(verticesCount, g.EdgeCount);

            foreach (var source in g.Vertices)
            {
                foreach (var target in g.Vertices)
                {
                    Assert.IsTrue(EdmondsAlgorithm.DFSSearch(source, target, g, out List <Edge <int> > path));
                }
            }
        }