private void AddConnectivity(GdbObjectReference objRef, int fromNodeIndex, int toNodeIndex, float weight, bool respectLineOrientation, ICollection <AdjacentNode> connectedNodesAtFrom, ICollection <AdjacentNode> connectedNodesAtTo) { // adjacency: int edgeIndex = EdgeReferences.Count; EdgeReferences.Add(objRef); // Allow adding the edge, even if its to point is outside the AOI and no connection can // be made. It is still relevant for the node degree count (number of edges at from). if (fromNodeIndex >= 0) { var fromToEdge = new AdjacentNode(toNodeIndex, weight, edgeIndex); connectedNodesAtFrom.Add(fromToEdge); } if (!respectLineOrientation && toNodeIndex >= 0) { var toFromEdge = new AdjacentNode(fromNodeIndex, weight, edgeIndex); connectedNodesAtTo.Add(toFromEdge); } }
private static AdjacentNode GetShortestEdge( [NotNull] IEnumerable <AdjacentNode> edges, int endNodeIndex) { double shortestLength = double.MaxValue; AdjacentNode result = null; foreach (AdjacentNode edge in edges) { if (edge.AdjacentNodeIndex != endNodeIndex) { continue; } if (edge.Weight < shortestLength) { shortestLength = edge.Weight; result = edge; } } return(result); }