public static void Helper_WeightNavGraphNodeEdges(SparseGraph graph, int node, double weight) { //make sure the node is present Debug.Assert(node < graph.NumNodes(), "Node can not exist in graph!"); //set the cost for each edge SparseGraph.EdgeIterator EdgeItr = new SparseGraph.EdgeIterator(graph, node); while (EdgeItr.MoveNext()) { //calculate the distance between nodes double dist = Vector2D.Vec2DDistance(graph.GetNode(EdgeItr.Current.From).Pos, graph.GetNode(EdgeItr.Current.To).Pos); //set the cost of this edge graph.SetEdgeCost(EdgeItr.Current.From, EdgeItr.Current.To, dist * weight); //if not a digraph, set the cost of the parallel edge to be the same if (!graph.isDigraph()) { graph.SetEdgeCost(EdgeItr.Current.To, EdgeItr.Current.From, dist * weight); } } }