Exemplo n.º 1
0
    public WeightedDirectedGraph(int vertexCount)
    {
        var vertices = new Vertex[vertexCount];

        for (int id = 0; id < vertexCount; ++id)
        {
            vertices[id] = new Vertex(this, id);
        }

        Vertices = vertices;
    }
Exemplo n.º 2
0
    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);
    }
Exemplo n.º 3
0
 public void AddEdge(Vertex startVertex, Vertex endVertex, int weight)
 => startVertex.AddNeighbor(endVertex, weight);
Exemplo n.º 4
0
 public int Update(Vertex key, int value)
 => Update(new KeyValuePair <Vertex, int>(key, value));
Exemplo n.º 5
0
 public int GetValue(Vertex key)
 => _keyValuePairs[_keyIndices[key]].Value;
Exemplo n.º 6
0
 public bool Contains(Vertex key)
 => _keyIndices.ContainsKey(key);
Exemplo n.º 7
0
 public void Add(Vertex key, int value)
 => Add(new KeyValuePair <Vertex, int>(key, value));
Exemplo n.º 8
0
 public BinaryHeap(Vertex topKey, int topValue = 0)
 {
     _keyValuePairs.Add(new KeyValuePair <Vertex, int>(topKey, topValue));
     _keyIndices.Add(topKey, 0);
 }