/// <summary> /// Adds and arc to an existing vertex. /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="data"></param> public void AddArc(long from, long to, RouterResolvedGraphEdge data) { RouterResolvedGraphVertex vertex; if (_vertices.TryGetValue(from, out vertex)) { KeyValuePair<long, RouterResolvedGraphEdge>[] arcs = vertex.Arcs; int idx = -1; if (arcs == null) { arcs = new KeyValuePair<long, RouterResolvedGraphEdge>[1]; idx = 0; vertex.Arcs = arcs; } else { idx = arcs.Length; Array.Resize<KeyValuePair<long, RouterResolvedGraphEdge>>(ref arcs, arcs.Length + 1); vertex.Arcs = arcs; } arcs[idx] = new KeyValuePair<long, RouterResolvedGraphEdge>( to, data); _vertices[from] = vertex; return; } throw new ArgumentOutOfRangeException("from"); }
/// <summary> /// Adds and arc to an existing vertex. /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="data"></param> public void AddArc(long from, long to, RouterResolvedGraphEdge data) { RouterResolvedGraphVertex vertex; if (_vertices.TryGetValue(from, out vertex)) { KeyValuePair <long, RouterResolvedGraphEdge>[] arcs = vertex.Arcs; int idx = -1; if (arcs == null) { arcs = new KeyValuePair <long, RouterResolvedGraphEdge> [1]; idx = 0; vertex.Arcs = arcs; } else { idx = arcs.Length; Array.Resize <KeyValuePair <long, RouterResolvedGraphEdge> >(ref arcs, arcs.Length + 1); vertex.Arcs = arcs; } arcs[idx] = new KeyValuePair <long, RouterResolvedGraphEdge>( to, data); _vertices[from] = vertex; return; } throw new ArgumentOutOfRangeException("from"); }