Example #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());
        }
Example #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++;
            }
        }
Example #3
0
        internal void AddFamily(Production production, SppfNode w, SppfNode v)
        {
            var family = new SppfFamilyDouble(production, w, v);

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