Exemplo 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");
                }
            }
        }
Exemplo n.º 2
0
        public static Paths GetPaths(Graph G, int s)
        {
            Paths p;

            //p = new DepthFirstPaths(G, s);
            p = new BreadthFirstPaths(G, s);
            return(p);
        }