Exemplo n.º 1
0
        public static string GetRawDot(SppfNode node)
        {
            var gb    = new GraphBuilder(node);
            var graph = gb.GetGraph();

            // var graph = ((SymbolNode)_node).GetGraph();
            return(graph.ToDot());
        }
Exemplo n.º 2
0
        public void PrintForest(SppfNode node, Dictionary <SppfNode, double> nodeProbs = null, string padding = "", HashSet <SppfNode> seen = null)
        {
            if (seen == null)
            {
                seen = new HashSet <SppfNode>();
            }

            var nodeProb = "";

            if (nodeProbs != null)
            {
                nodeProb = " p=" + nodeProbs[node];
            }

            Console.WriteLine("{0}{1}{2}", padding, node, nodeProb);

            var l             = node.Families;
            var familiesCount = l.Count();

            if (familiesCount > 0 && seen.Contains(node))
            {
                Console.WriteLine("{0}Already seen this node!", padding);
                return;
            }
            seen.Add(node);

            var i = 0;

            foreach (var alternative in l)
            {
                // for (int i = 0; i < l.Count; i++) {
                // var alternative = l[i];
                if (familiesCount > 1)
                {
                    Console.WriteLine("{0}Alternative {1}", padding, i);
                }
                foreach (var member in alternative.Members)
                {
                    PrintForest(member, nodeProbs, padding + "  ", seen);
                }
                i++;
            }
        }
Exemplo n.º 3
0
        internal void AddFamily(Production production, SppfNode w, SppfNode v)
        {
            var family = new SppfFamilyDouble(production, w, v);

            _families.Add(family);
        }
Exemplo n.º 4
0
 public SppfFamilySingle(Production production, SppfNode v) : base(production)
 {
     _firstChild = v;
 }
Exemplo n.º 5
0
 public SppfFamilyDouble(Production production, SppfNode w, SppfNode v) : base(production)
 {
     _firstChild  = w;
     _secondChild = v;
 }