Exemple #1
0
        static void Main(string[] args)
        {
            var graph1 = new Graph();

            graph1.InsertNodes(5);
            graph1.InsertEdge(0, 2);
            graph1.InsertEdge(2, 4);
            graph1.InsertEdge(4, 1);
            graph1.InsertEdge(1, 3);
            graph1.InsertEdge(3, 0);

            var graph2 = new Graph();

            graph2.InsertNodes(5);
            graph2.InsertEdge(0, 1);
            graph2.InsertEdge(1, 4);
            graph2.InsertEdge(4, 3);
            graph2.InsertEdge(3, 2);
            graph2.InsertEdge(2, 0);

            var vfs   = new VfState(graph1, graph2, false);
            var match = vfs.FMatch();

            Console.OutputEncoding = Encoding.UTF8;
            Console.WriteLine(match ? "Графи ізоморфні" : "Графи не ізоморфні");
            if (match)
            {
                for (int i = 0; i < 5; i++)
                {
                    Console.WriteLine(i + " -> " + vfs.Mapping1To2[i]);
                }
            }
            Console.ReadKey();
        }
Exemple #2
0
        public double matchPercent(string file1, string file2)
        {
            //MessageBox.Show(String.Concat(file1, "\t", file2));
            Graph graph = new Graph();

            Console.WriteLine("Graph 1 detail ------\n\n");
            graph = readNetlist(file1);

            Console.WriteLine("Graph 2 detail ------\n\n");
            Graph graph2 = new Graph();

            graph2 = readNetlist(file2);

            bool f = graph2.doesEdgeExist(0, 4);

            Console.WriteLine(String.Concat("Does edge exist = ", f.ToString()));
            List <int> neighbors = graph2.GetNeighbors(5);

            for (int i = 0; i < neighbors.Count; i++)
            {
                Console.Write(String.Concat(neighbors[i].ToString(), "\t"));
            }
            Console.WriteLine("");
            neighbors.Clear();
            neighbors = graph2.GetOutNeighbors(7);
            for (int i = 0; i < neighbors.Count; i++)
            {
                Console.Write(String.Concat(neighbors[i].ToString(), "\t"));
            }

            List <string> cliques = graph2.GetCliques();
            int           count   = 0;

            for (int i = 0; i < cliques.Count; i++)
            {
                char[] delims = { ' ', '\t' };
                //Graph gtemp = new Graph();
                Graph gtemp = getGraphFromPath(cliques[i], graph2);

                //Console.WriteLine(gtemp.GetInfo());
                VfState vfs         = new VfState(graph, gtemp, false, true);
                bool    fIsomorphic = vfs.FMatch();
                if (fIsomorphic)
                {
                    count++;
                }
                Console.WriteLine(String.Concat("clique (", i.ToString(), ") value = ",
                                                cliques[i], " Match = ", fIsomorphic.ToString()));
            }

            double percent = ((double)count / cliques.Count) * 100.0;

            //MessageLogWindow mlw = new MessageLogWindow(logtext);
            //mlw.Show();
            //MessageBox.Show(String.Concat("Percent match = ", percent.ToString()));
            return(percent);
            //return 21.3;
        }
        public double matchPercent(string file1, string file2)
        {
            //MessageBox.Show(String.Concat(file1, "\t", file2));
            Graph graph = new Graph();
            Console.WriteLine("Graph 1 detail ------\n\n");
            graph = readNetlist(file1);

            Console.WriteLine("Graph 2 detail ------\n\n");
            Graph graph2 = new Graph();
            graph2 = readNetlist(file2);

            bool f = graph2.doesEdgeExist(0, 4);
            Console.WriteLine(String.Concat("Does edge exist = ", f.ToString()));
            List<int> neighbors = graph2.GetNeighbors(5);
            for (int i = 0; i < neighbors.Count; i++)
            {
                Console.Write(String.Concat(neighbors[i].ToString(), "\t"));

            }
            Console.WriteLine("");
            neighbors.Clear();
            neighbors = graph2.GetOutNeighbors(7);
            for (int i = 0; i < neighbors.Count; i++)
            {
                Console.Write(String.Concat(neighbors[i].ToString(), "\t"));

            }

            List<string> cliques = graph2.GetCliques();
            int count = 0;
            for (int i = 0; i < cliques.Count; i++)
            {
                char[] delims = { ' ', '\t' };
                //Graph gtemp = new Graph();
                Graph gtemp = getGraphFromPath(cliques[i], graph2);

                //Console.WriteLine(gtemp.GetInfo());
                VfState vfs = new VfState(graph, gtemp, false, true);
                bool fIsomorphic = vfs.FMatch();
                if (fIsomorphic) count++;
                Console.WriteLine(String.Concat("clique (", i.ToString(), ") value = ",
                    cliques[i], " Match = ", fIsomorphic.ToString()));

            }

            double percent = ((double)count / cliques.Count) * 100.0;
            //MessageLogWindow mlw = new MessageLogWindow(logtext);
            //mlw.Show();
            //MessageBox.Show(String.Concat("Percent match = ", percent.ToString()));
            return percent;
            //return 21.3;
        }