pub fn execute<W, E: Edge<W>, G>(mut self, graph: &G) -> Vec<usize>
    where
        G: provide::Graph<W, E, DirectedEdge> + provide::Vertices + provide::Neighbors,
    {
        // This algorithm uses dfs to sort the vertices.
        // It stores each vertex the moment dfs visits all its children(vertex color goes black).
        // So a parent will get added after all its children are visited.
        let mut dfs = Dfs::init(graph, &mut self);

        dfs.execute(graph);

        let dfs = dfs;

        let id_map = dfs.dissolve().2;

        // Because a parent is added after its children but in topological order it must be visited first, the order of the vertices added during dfs must be reversed.
        self.sorted_vertex_ids.reverse();

        self.sorted_vertex_ids
            .iter()
            .map(|virt_id| id_map.real_id_of(*virt_id))
            .collect()
    }
/// Finds the topological sort of vertices.
///
/// # Arguments
/// `graph`: Graph to sort its vertices topologically.
///
/// # Returns
/// Sorted ids of vertices.
Finds the topological sort of vertices.
Finds the topological sort of vertices .
pub fn execute<W, E: Edge<W>, G>(mut self, graph: &G) -> Vec<usize>
    where
        G: provide::Graph<W, E, DirectedEdge> + provide::Vertices + provide::Neighbors,
    {
        // This algorithm uses dfs to sort the vertices.
        // It stores each vertex the moment dfs visits all its children(vertex color goes black).
        // So a parent will get added after all its children are visited.
        let mut dfs = Dfs::init(graph, &mut self);
        dfs.execute(graph);
        let dfs = dfs;
        let id_map = dfs.dissolve().2;
        // Because a parent is added after its children but in topological order it must be visited first, the order of the vertices added during dfs must be reversed.
        self.sorted_vertex_ids.reverse();
        self.sorted_vertex_ids
            .iter()
            .map(|virt_id| id_map.real_id_of(*virt_id))
            .collect()
    }
pub fn execute < W , E : Edge < W > , G > ( mut self , graph : & G ) -> Vec < usize > where G : provide :: Graph < W , E , DirectedEdge > + provide :: Vertices + provide :: Neighbors , { // This algorithm uses dfs to sort the vertices. // It stores each vertex the moment dfs visits all its children(vertex color goes black). // So a parent will get added after all its children are visited. let mut dfs = Dfs :: init ( graph , & mut self ) ; dfs . execute ( graph ) ; let dfs = dfs ; let id_map = dfs . dissolve ( ) . 2 ; // Because a parent is added after its children but in topological order it must be visited first, the order of the vertices added during dfs must be reversed. self . sorted_vertex_ids . reverse ( ) ; self . sorted_vertex_ids . iter ( ) . map ( | virt_id | id_map . real_id_of ( * virt_id ) ) . collect ( ) }
Finds the topological sort of vertices.
Finds the topological sort of vertices .
mut self
graph
&G
Sorted ids of vertices.
Sorted ids of vertices .
mut self
graph
&G