public PathCalculator(GraphBase graph, int sourceId)
        {
            _marked = new Boolean[graph.NodesCount];
            _distTo = new int[graph.NodesCount];
            _edgeTo = new int[graph.NodesCount];

            for (var v = 0; v < graph.NodesCount; v++) _distTo[v] = INFINITY;
            Search(graph, sourceId);
        }
 private void Search(GraphBase graph, int sourceId)
 {
     var queue = new Queue<int>();
     _marked[sourceId] = true;
     _distTo[sourceId] = 0;
     queue.Enqueue(sourceId);
     while (queue.Count > 0)
     {
         var nodeId = queue.Dequeue();
         foreach (var visited in graph.Adjacents(nodeId).Where(visited => !_marked[visited]))
         {
             _edgeTo[visited] = nodeId;
             _distTo[visited] = _distTo[nodeId] + 1;
             _marked[visited] = true;
             queue.Enqueue(visited);
         }
     }
 }