예제 #1
0
        /// <summary>
        /// Merges vertex2 into vertex1.
        /// </summary>
        public static void MergeVertices(this RoutingNetwork network, uint vertex1, uint vertex2)
        {
            // get and save edge for vertex2.
            var vertex2Edges = new List <RoutingEdge>(network.GetEdgeEnumerator(vertex2));

            // remove edges.
            network.RemoveEdges(vertex2);

            // add edges.
            for (var i = 0; i < vertex2Edges.Count; i++)
            {
                if (vertex1 == vertex2Edges[i].To)
                {
                    continue;
                }

                if (!vertex2Edges[i].DataInverted)
                { // not inverted, add as vertex1 -> to.
                    network.AddEdge(vertex1, vertex2Edges[i].To, vertex2Edges[i].Data, vertex2Edges[i].Shape);
                }
                else
                { // inverted, add as to -> vertex1.
                    network.AddEdge(vertex2Edges[i].To, vertex1, vertex2Edges[i].Data, vertex2Edges[i].Shape);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Returns true if the routing network contains an edge between the two given vertices.
        /// </summary>
        public static bool ContainsEdge(this RoutingNetwork network, uint vertex1, uint vertex2)
        {
            var edges = network.GetEdgeEnumerator(vertex1);

            while (edges.MoveNext())
            {
                if (edges.To == vertex2)
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #3
0
 /// <summary>
 /// Gets all edges starting at this edges.
 /// </summary>
 public static List <RoutingEdge> GetEdges(this RoutingNetwork network, uint vertex)
 {
     return(new List <RoutingEdge>(network.GetEdgeEnumerator(vertex)));
 }