Ejemplo n.º 1
0
        public static void Test(string filename, char delimiter, string query = null)
        {
            var             sg   = new SymbolGraph(filename, delimiter);
            Action <string> show = (key) => Console.WriteLine(string.Format("{0} : [{1}]\n", key, String.Join(",", sg.GetAdjacent(key))));

            if (query != null)
            {
                show(query);
            }
            else
            {
                Array.ForEach(sg.keys, show);
            }
        }
Ejemplo n.º 2
0
        public static void Main(string filename, char delimitor, string source, string sink)
        {
            SymbolGraph symbolGraph = new SymbolGraph(filename, delimitor);

            if (!symbolGraph.Contains(source))
            {
                Console.WriteLine(string.Format("Source {0} is out of DB", source));
            }

            if (!symbolGraph.Contains(sink))
            {
                Console.WriteLine(string.Format("Sink {0} is out of DB", sink));
            }

            int                  sourceIndex = symbolGraph.GetIndex(source);
            int                  sinkIndex   = symbolGraph.GetIndex(sink);
            BfsPaths             bfsTree     = new BfsPaths(symbolGraph.Graph, sourceIndex);
            IEnumerable <string> paths       = bfsTree.PathTo(sinkIndex).Select(index => symbolGraph.GetName(index));

            Console.WriteLine(string.Format("{0} -> {1}\n {2}", source, sink, String.Join("\n ", paths)));
        }