pub mod pk;
use crate::engine::graph::DependencyGraph;
use crate::engine::vertex::VertexId;
#[derive(Clone, Copy, Debug)]
pub struct GraphAdapter<'a> {
pub g: &'a DependencyGraph,
}
impl<'a> GraphAdapter<'a> {
pub fn new(g: &'a DependencyGraph) -> Self {
Self { g }
}
}
impl pk::GraphView<VertexId> for GraphAdapter<'_> {
fn successors(&self, n: VertexId, out: &mut Vec<VertexId>) {
out.clear();
out.extend(self.g.get_dependents(n));
}
fn predecessors(&self, n: VertexId, out: &mut Vec<VertexId>) {
out.clear();
out.extend(self.g.get_dependencies(n));
}
fn exists(&self, n: VertexId) -> bool {
self.g.vertex_exists(n)
}
}