protected int FindEdge(int currentNode, int nxt, out bool rev) { NodeAddress node = m_top.NodeAt(currentNode); double minDist = double.MaxValue; int bestEi = -1; rev = false; for (int j = 0; j < node.EdgeCount; j++) { var ei = node.EdgeIndexAt(j, m_top); var edge = m_top.EdgeAt(ei); if (edge.OtherVertex(currentNode) == nxt) { if (m_dist[ei] < minDist) { rev = node.RevAt(j, m_top); bestEi = ei; minDist = m_dist[ei]; } } } if (bestEi == -1) { throw new KeyNotFoundException("Vertex currentNode is not linked to nxt"); } return(bestEi); }
/// <summary> /// Retrieves the Topology edge of the Edge at position i at this Node /// </summary> /// <param name="i">An edge index smaller than EdgeCount and larger than 0</param> /// <param name="top">The reference topology</param> /// <returns>The Topology edge</returns> public EdgeAddress EdgeAt(int i, CurvesTopology top) { if (i < 0 || i >= EdgeCount) { throw new ArgumentOutOfRangeException("i", "index must be smaller than EdgeCount and larger than 0"); } return(top.EdgeAt(EdgeIndexAt(i, top))); }