public WeightedDirectedGraph(int vertexCount) { var vertices = new Vertex[vertexCount]; for (int id = 0; id < vertexCount; ++id) { vertices[id] = new Vertex(this, id); } Vertices = vertices; }
public bool TryGetValue(Vertex key, out int value) { int keyIndex; if (_keyIndices.TryGetValue(key, out keyIndex)) { value = _keyValuePairs[keyIndex].Value; return(true); } value = default(int); return(false); }
public void AddEdge(Vertex startVertex, Vertex endVertex, int weight) => startVertex.AddNeighbor(endVertex, weight);
public int Update(Vertex key, int value) => Update(new KeyValuePair <Vertex, int>(key, value));
public int GetValue(Vertex key) => _keyValuePairs[_keyIndices[key]].Value;
public bool Contains(Vertex key) => _keyIndices.ContainsKey(key);
public void Add(Vertex key, int value) => Add(new KeyValuePair <Vertex, int>(key, value));
public BinaryHeap(Vertex topKey, int topValue = 0) { _keyValuePairs.Add(new KeyValuePair <Vertex, int>(topKey, topValue)); _keyIndices.Add(topKey, 0); }