Ejemplo n.º 1
0
        public void RunDegreeOfSeperation(string filename, char delim, string source)
        {
            SymbolGraph       sg    = new SymbolGraph(filename, delim);
            Graph             G     = sg.G();
            int               s     = sg.Index(source);
            BreadthFirstPaths paths = new BreadthFirstPaths(G, s);
            string            target;

            while (!string.IsNullOrEmpty(target = Console.ReadLine()))
            {
                if (sg.Contains(target))
                {
                    int t = sg.Index(target);
                    if (paths.HasPathTo(t))
                    {
                        var path = paths.PathTo(t);
                        foreach (var v in path)
                        {
                            var vertice = sg.Name(v);
                            Console.WriteLine(" {0}", vertice);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Not Connected");
                    }
                }
                else
                {
                    Console.WriteLine("Not in database");
                }
            }
        }
Ejemplo n.º 2
0
        public void RunSymbolGraph(string filename, char delim)
        {
            SymbolGraph sg = Factory.GetSymbolGraph(filename, delim);
            Graph       G  = sg.G();
            string      source;

            while (!string.IsNullOrEmpty(source = Console.ReadLine()))
            {
                foreach (int w in G.Adj(sg.Index(source)))
                {
                    Console.WriteLine(" " + sg.Name(w));
                }
            }
        }