You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: lr_planar.rs
    path of file: ./repos/rustworkx/rustworkx-core/src/planar
    
    the code of the file until where you have to start completion: // Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.

use std::cmp::Ordering;
use std::hash::Hash;
use std::vec::IntoIter;

use hashbrown::{hash_map::Entry, HashMap};
use petgraph::{
    visit::{
        EdgeCount, EdgeRef, GraphBase, GraphProp, IntoEdges, IntoNodeIdentifiers, NodeCount,
        Visitable,
    },
    Undirected,
};

use crate::traversal::{depth_first_search, DfsEvent};

type Edge<G> = (<G as GraphBase>::NodeId, <G as GraphBase>::NodeId);

fn modify_if_min<K, V>(xs: &mut HashMap<K, V>, key: K, val: V)
where
    K: Hash + Eq,
    V: Ord + Copy,
{
    xs.entry(key).and_modify(|e| {
        if val < *e {
            *e = val;
        }
    });
}

fn edges_filtered_and_sorted_by<G, P, F, K>(
    graph: G,
    a: G::NodeId,
    filter: P,
    compare: F,
) -> IntoIter<Edge<G>>
where
    G: IntoEdges,
    P: Fn(&Edge<G>) -> bool,
    F: Fn(&Edge<G>) -> K,
    K: Ord,
{
    let mut edges = graph
        .edges(a)
        .filter_map(|edge| {
            let e = (edge.source(), edge.target());
            if filter(&e) {
                Some(e)
            } else {
                None
            }
        })
        .collect::<Vec<_>>();
    edges.sort_by_key(compare);
    // Remove parallel edges since they do *not* affect whether a graph is planar.
    edges.d
    
    fn lr_orientation_visitor(&mut self, event: DfsEvent<G::NodeId, &G::EdgeWeight>) {
        match event {
            DfsEvent::Discover(v, _) => {
                if let Entry::Vacant(entry) = self.height.entry(v) {
                    entry.insert(0);
                    self.roots.push(v);
                }
            }
            DfsEvent::TreeEdge(v, w, _) => {
                let ei = (v, w);
                let v_height = self.height[&v];
                let w_height = v_height + 1;

                self.eparent.insert(w, ei);
                self.height.insert(w, w_height);
                // now initialize low points.
                self.lowpt.insert(ei, v_height);
                self.lowpt_2.insert(ei, w_height);
            }
            DfsEvent::BackEdge(v, w, _) => {
                // do *not* consider ``(v, w)`` as a back edge if ``(w, v)`` is a tree edge.
                if Some(&(w, v)) != self.eparent.get(&v) {
                    let ei = (v, w);
                    self.lowpt.insert(ei, self.height[&w]);
                    self.lowpt_2.insert(ei, self.height[&v]);
                }
            }
            DfsEvent::Finish(v, _) => {
                for edge in self.graph.edges(v) {
                    let w = edge.target();
                    let ei = (v, w);

                    // determine nesting depth.
                    let low = match self.lowpt.get(&ei) {
                        Some(val) => *val,
                        None =>
                        // if ``lowpt`` does *not* contain edge ``(v, w)``, it means
                        // that it's *not* a tree or a back edge so we skip it since
                        // it's oriented in the reverse direction.
                        {
                            continue
                        }
                    };

                    if self.lowpt_2[&ei] < self.height[&v] {
                        // if it's chordal, add one.
                        self.nesting_depth.insert(ei, 2 * low + 1);
                    } else {
                        self.nesting_depth.insert(ei, 2 * low);
                    }

                    // update lowpoints of parent edge.
                    if let Some(e_par) = self.eparent.get(&v) {
                        match self.lowpt[&ei].cmp(&self.lowpt[e_par]) {
                            Ordering::Less => {
                                self.lowpt_2
                                    .insert(*e_par, self.lowpt[e_par].min(self.lowpt_2[&ei]));
                                self.lowpt.insert(*e_par, self.lowpt[&ei]);
                            }
                            Ordering::Greater => {
                                modify_if_min(&mut self.lowpt_2, *e_par, self.lowpt[&ei]);
                            }
                            _ => {
                                let val = self.lowpt_2[&ei];
                                modify_if_min(&mut self.lowpt_2, *e_par, val);
                            }
                        }
                    }
                }
            }
            _ => {}
        }
    }