Пример #1
0
        /**
         * {@inheritDoc}
         */
        public override HashSet <E> edgesOf(V vertex)
        {
            ArrayUnenforcedSet <E> inAndOut = new ArrayUnenforcedSet <E>(getEdgeContainer(vertex).incoming);

            inAndOut.AddRange(getEdgeContainer(vertex).outgoing);

            // we have two copies for each self-loop - remove one of them.
            if (abstractBaseGraph.isAllowingLoops())
            {
                HashSet <E> loops = getAllEdges(vertex, vertex);

                for (int i = 0; i < inAndOut.Count;)
                {
                    E e = inAndOut[i];

                    if (loops.Contains(e))
                    {
                        inAndOut.RemoveAt(i);
                        loops.Remove(e); // so we remove it only once
                    }
                    else
                    {
                        i++;
                    }
                }
            }

            return(new HashSet <E>(inAndOut));
        }