Пример #1
0
        public PathEdge Splice(PathEdge other)
        {
            IAtom        intersection = GetIntersection(other.atoms);
            List <IAtom> newAtoms     = new List <IAtom>(atoms);

            if (atoms[0] == intersection)
            {
                newAtoms.Reverse();
            }

            if (other.atoms[0] == intersection)
            {
                for (int i = 1; i < other.atoms.Count; i++)
                {
                    newAtoms.Add(other.atoms[i]);
                }
            }
            else
            {
                for (int i = other.atoms.Count - 2; i >= 0; i--)
                {
                    newAtoms.Add(other.atoms[i]);
                }
            }

            if (!IsRealPath(newAtoms))
            {
                return(null);
            }

            return(new PathEdge(newAtoms));
        }
Пример #2
0
        private static IEnumerable <PathEdge> SpliceEdges(List <PathEdge> edges)
        {
            for (int i = 0; i < edges.Count; i++)
            {
                for (int j = i + 1; j < edges.Count; j++)
                {
                    PathEdge splice = edges[j].Splice(edges[i]);

                    if (splice != null)
                    {
                        yield return(splice);
                    }
                }
            }
            yield break;
        }