/// <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); } } }
/// <summary> /// Adds a new edge. /// </summary> public static uint AddEdge(this RoutingNetwork network, uint vertex1, uint vertex2, Edges.EdgeData data, IEnumerable <Coordinate> shape) { if (shape == null) { return(network.AddEdge(vertex1, vertex2, data, (ShapeEnumerable)null)); } return(network.AddEdge(vertex1, vertex2, data, new ShapeEnumerable(shape))); }
/// <summary> /// Adds a new edge. /// </summary> public static uint AddEdge(this RoutingNetwork network, uint vertex1, uint vertex2, ushort profile, uint metaId, float distance, IEnumerable <Coordinate> shape) { return(network.AddEdge(vertex1, vertex2, new Edges.EdgeData() { Distance = distance, MetaId = metaId, Profile = profile }, new ShapeEnumerable(shape))); }
/// <summary> /// Adds a new edge. /// </summary> public static uint AddEdge(this RoutingNetwork network, uint vertex1, uint vertex2, Edges.EdgeData data, params Coordinate[] shape) { return(network.AddEdge(vertex1, vertex2, data, new ShapeEnumerable(shape))); }