// assumes that the path already has EPSILON as the last element.
        public static void AddOnePathToGraph(IList path, double count, int markovOrder, TransducerGraph graph)
        {
            object source = graph.GetStartNode();

            for (int j = 0; j < path.Count; j++)
            {
                object input          = path[j];
                TransducerGraph.Arc a = graph.GetArcBySourceAndInput(source, input);
                if (a != null)
                {
                    // increment the arc weight
                    a.output = ((double)a.output) + count;
                }
                else
                {
                    object target;
                    if (input.Equals(TransducerGraph.EpsilonInput))
                    {
                        target = "END";
                    }
                    else
                    {
                        // to ensure they all share the same end node
                        if (markovOrder == 0)
                        {
                            // we all transition back to the same state
                            target = source;
                        }
                        else
                        {
                            if (markovOrder > 0)
                            {
                                // the state is described by the partial history
                                target = path.SubList((j < markovOrder ? 0 : j - markovOrder + 1), j + 1);
                            }
                            else
                            {
                                // the state is described by the full history
                                target = path.SubList(0, j + 1);
                            }
                        }
                    }
                    double output = count;
                    a = new TransducerGraph.Arc(source, target, input, output);
                    graph.AddArc(a);
                }
                source = a.GetTargetNode();
            }
            graph.SetEndNode(source);
        }