Пример #1
0
        /// <summary>
        /// Gets the target vertex.
        /// </summary>
        public static uint GetTargetVertex(this Graph.EdgeEnumerator enumerator, long directedEdgeId)
        {
            enumerator.MoveToEdge(directedEdgeId);

            if (directedEdgeId > 0)
            {
                if (!enumerator.DataInverted)
                {
                    return(enumerator.To);
                }
                else
                {
                    return(enumerator.From);
                }
            }
            else
            {
                if (enumerator.DataInverted)
                {
                    return(enumerator.To);
                }
                else
                {
                    return(enumerator.From);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Gets the weight for the given edge.
        /// </summary>
        public static float GetWeight(this Graph.EdgeEnumerator enumerator, long directedEdgeId, Func <ushort, Factor> getFactor, out short direction)
        {
            enumerator.MoveToEdge(directedEdgeId);
            float  distance;
            ushort edgeProfile;

            Data.Edges.EdgeDataSerializer.Deserialize(enumerator.Data0, out distance, out edgeProfile);
            var factor = getFactor(edgeProfile);

            direction = factor.Direction;
            return(factor.Value * distance);
        }
Пример #3
0
        /// <summary>
        /// Moves to the given directed edge-id.
        /// </summary>
        public static void MoveToEdge(this Graph.EdgeEnumerator enumerator, long directedEdgeId)
        {
            if (directedEdgeId == 0)
            {
                throw new ArgumentOutOfRangeException("directedEdgeId");
            }

            uint edgeId;

            if (directedEdgeId > 0)
            {
                edgeId = (uint)directedEdgeId - 1;
            }
            else
            {
                edgeId = (uint)((-directedEdgeId) - 1);
            }
            enumerator.MoveToEdge(edgeId);
        }