pub struct Graph {
pub adj: HashMap<Point, Vec<Edge>>,
pub source: Point,
pub sink: Point,
}Expand description
Represents the entire flow network, including all nodes and edges.
Fields§
§adj: HashMap<Point, Vec<Edge>>§source: Point§sink: PointImplementations§
Source§impl Graph
impl Graph
Sourcepub fn new(source: Point, sink: Point) -> Self
pub fn new(source: Point, sink: Point) -> Self
Creates a new, empty graph with a defined source and sink.
Sourcepub fn add_node(&mut self, node: Point)
pub fn add_node(&mut self, node: Point)
Adds a new node to the graph. Ensures a node exists in the adjacency list, even if it has no outgoing edges.
Sourcepub fn add_edge(&mut self, from: Point, to: Point, capacity: u64, cost: f64)
pub fn add_edge(&mut self, from: Point, to: Point, capacity: u64, cost: f64)
Adds a directed edge to the graph. This will be the primary way we build our network from the maze or automaton state.
Sourcepub fn get_edges(&self, node: &Point) -> &Vec<Edge>
pub fn get_edges(&self, node: &Point) -> &Vec<Edge>
A helper to get all outgoing edges from a given node.
Sourcepub fn edmonds_karp(&mut self) -> u64
pub fn edmonds_karp(&mut self) -> u64
Calculates the maximum flow, now using a cost-aware pathfinding method.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnwindSafe for Graph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more