public static function find_sources(Digraph $graph, DepthFirstVisitorInterface $visitor) {
        $incomings = new \SplObjectStorage();
        $queue = new \SplQueue();

        foreach ($graph->edges() as $edge) {
            if (!isset($incomings[$edge[1]])) {
                $incomings[$edge[1]] = new \SplObjectStorage();
            }
            $incomings[$edge[1]]->attach($edge[0]);
        }

        // Prime the queue with vertices that have no incoming edges.
        foreach ($graph->vertices() as $vertex) {
            if (!$incomings->contains($vertex)) {
                $queue->push($vertex);
                $visitor->onInitializeVertex($vertex, TRUE, $queue);
            }
            else {
                $visitor->onInitializeVertex($vertex, FALSE, $queue);
            }
        }

        return $queue;
    }