[−][src]Struct contest_algorithms::graph::Graph
A compact graph representation. Edges are numbered in order of insertion. Each adjacency list consists of all edges pointing out from a given vertex.
Implementations
impl Graph
[src]
pub fn euler_path(&self, u: usize) -> Vec<usize>
[src]
Finds the sequence of edges in an Euler path starting from u, assuming it exists and that the graph is directed. Undefined behavior if this precondition is violated. To extend this to undirected graphs, maintain a visited array to skip the reverse edge.
pub fn min_spanning_tree(&self, weights: &[i64]) -> Vec<usize>
[src]
Kruskal's minimum spanning tree algorithm on an undirected graph.
pub fn dijkstra(&self, weights: &[u64], u: usize) -> Vec<u64>
[src]
pub fn dfs(&self, u: usize) -> DfsIterator
[src]
impl Graph
[src]
pub fn new(vmax: usize, emax_hint: usize) -> Self
[src]
Initializes a graph with vmax vertices and no edges. To reduce unnecessary allocations, emax_hint should be close to the number of edges that will be inserted.
pub fn num_v(&self) -> usize
[src]
Returns the number of vertices.
pub fn num_e(&self) -> usize
[src]
Returns the number of edges, double-counting undirected edges.
pub fn add_edge(&mut self, u: usize, v: usize)
[src]
Adds a directed edge from u to v.
pub fn add_undirected_edge(&mut self, u: usize, v: usize)
[src]
An undirected edge is two directed edges. If edges are added only via this funcion, the reverse of any edge e can be found at e^1.
pub fn add_two_sat_clause(&mut self, u: usize, v: usize)
[src]
If we think of each even-numbered vertex as a variable, and its odd-numbered successor as its negation, then we can build the implication graph corresponding to any 2-CNF formula. Note that u||v == !u -> v == !v -> u.
pub fn adj_list(&self, u: usize) -> AdjListIteratorⓘImportant traits for AdjListIterator<'a>
impl<'a> Iterator for AdjListIterator<'a> type Item = (usize, usize);
[src]
Important traits for AdjListIterator<'a>
impl<'a> Iterator for AdjListIterator<'a> type Item = (usize, usize);
Gets vertex u's adjacency list.
Auto Trait Implementations
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnwindSafe for Graph
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,