pub fn to_directed(&self, py: Python) -> crate::digraph::PyDiGraph {
        let node_count = self.node_count();
        let mut new_graph = StablePyGraph::<Directed>::with_capacity(
            node_count,
            2 * self.graph.edge_count(),
        );
        let mut node_map: HashMap<NodeIndex, NodeIndex> =
            HashMap::with_capacity(node_count);
        for node_index in self.graph.node_indices() {
            let node = self.graph[node_index].clone_ref(py);
            let new_index = new_graph.add_node(node);
            node_map.insert(node_index, new_index);
        }
        for edge in self.graph.edge_references() {
            let &source = node_map.get(&edge.source()).unwrap();
            let &target = node_map.get(&edge.target()).unwrap();
            let weight = edge.weight();
            new_graph.add_edge(source, target, weight.clone_ref(py));
            new_graph.add_edge(target, source, weight.clone_ref(py));
        }
        crate::digraph::PyDiGraph {
            graph: new_graph,
            node_removed: false,
            cycle_state: algo::DfsSpace::default(),
            check_cycle: false,
            multigraph: self.multigraph,
        }
    }
/// Generate a new :class:`~retworkx.PyDiGraph` object from this graph
///
/// This will create a new :class:`~retworkx.PyDiGraph` object from this
/// graph. All edges in this graph will result in a bidirectional edge
/// pair in the output graph.
///
/// .. note::
///
///     The node indices in the output :class:`~retworkx.PyDiGraph` may
///     differ if nodes have been removed.
///
/// :returns: A new :class:`~retworkx.PyDiGraph` object with a
///     bidirectional edge pair for each edge in this graph. Also all
///     node and edge weights/data payloads are copied by reference to
///     the output graph
/// :rtype: PyDiGraph
Generate a new :class:`~retworkx.PyDiGraph` object from this graph
This will create a new :class:`~retworkx.PyDiGraph` object from this
graph. All edges in this graph will result in a bidirectional edge
pair in the output graph.



The node indices in the output :class:`~retworkx.PyDiGraph` may
differ if nodes have been removed.

:returns: A new :class:`~retworkx.PyDiGraph` object with a
bidirectional edge pair for each edge in this graph. Also all
node and edge weights/data payloads are copied by reference to
the output graph
:rtype: PyDiGraph
Generate a new : class : ` ~retworkx . PyDiGraph ` object from this graph This will create a new : class : ` ~retworkx . PyDiGraph ` object from this graph . All edges in this graph will result in a bidirectional edge pair in the output graph . The node indices in the output : class : ` ~retworkx . PyDiGraph ` may differ if nodes have been removed . : returns : A new : class : ` ~retworkx . PyDiGraph ` object with a bidirectional edge pair for each edge in this graph . Also all node and edge weights / data payloads are copied by reference to the output graph : rtype : PyDiGraph
pub fn to_directed(&self, py: Python) -> crate::digraph::PyDiGraph {
        let node_count = self.node_count();
        let mut new_graph = StablePyGraph::<Directed>::with_capacity(
            node_count,
            2 * self.graph.edge_count(),
        );
        let mut node_map: HashMap<NodeIndex, NodeIndex> =
            HashMap::with_capacity(node_count);
        for node_index in self.graph.node_indices() {
            let node = self.graph[node_index].clone_ref(py);
            let new_index = new_graph.add_node(node);
            node_map.insert(node_index, new_index);
        }
        for edge in self.graph.edge_references() {
            let &source = node_map.get(&edge.source()).unwrap();
            let &target = node_map.get(&edge.target()).unwrap();
            let weight = edge.weight();
            new_graph.add_edge(source, target, weight.clone_ref(py));
            new_graph.add_edge(target, source, weight.clone_ref(py));
        }
        crate::digraph::PyDiGraph {
            graph: new_graph,
            node_removed: false,
            cycle_state: algo::DfsSpace::default(),
            check_cycle: false,
            multigraph: self.multigraph,
        }
    }
pub fn to_directed ( & self , py : Python ) -> crate :: digraph :: PyDiGraph { let node_count = self . node_count ( ) ; let mut new_graph = StablePyGraph :: < Directed > :: with_capacity ( node_count , 2 * self . graph . edge_count ( ) , ) ; let mut node_map : HashMap < NodeIndex , NodeIndex > = HashMap :: with_capacity ( node_count ) ; for node_index in self . graph . node_indices ( ) { let node = self . graph [ node_index ] . clone_ref ( py ) ; let new_index = new_graph . add_node ( node ) ; node_map . insert ( node_index , new_index ) ; } for edge in self . graph . edge_references ( ) { let & source = node_map . get ( & edge . source ( ) ) . unwrap ( ) ; let & target = node_map . get ( & edge . target ( ) ) . unwrap ( ) ; let weight = edge . weight ( ) ; new_graph . add_edge ( source , target , weight . clone_ref ( py ) ) ; new_graph . add_edge ( target , source , weight . clone_ref ( py ) ) ; } crate :: digraph :: PyDiGraph { graph : new_graph , node_removed : false , cycle_state : algo :: DfsSpace :: default ( ) , check_cycle : false , multigraph : self . multigraph , } }
Generate a new :class:`~retworkx.PyDiGraph` object from this graph
This will create a new :class:`~retworkx.PyDiGraph` object from this
graph.
Generate a new : class : ` ~retworkx . PyDiGraph ` object from this graph This will create a new : class : ` ~retworkx . PyDiGraph ` object from this graph .
&self
py
Python
&self
py
Python