[−][src]Struct graph_solver::Graph
Stores information about graph.
An edge value 0
means no edge.
Fields
nodes: Vec<Node>
Nodes.
edges: Vec<Vec<Color>>
Edges.
pairs: Vec<(usize, usize)>
Pair constraints, using indices.
no_triangles: bool
Whether triangle cycles are allowed.
meet_quad: bool
Whether any shortest cycle for any vertex must be 4 or less.
connected: bool
Whether any node can be reached from any other node.
Implementations
impl Graph
[src]
pub fn new() -> Graph
[src]
Creates a new graph.
Initialized with these default settings:
- no-triangles: false
- meet-quad: false
- connected: false
pub fn graphviz(
&self,
layout: &str,
node_colors: &[&str],
edge_colors: &[&str]
) -> String
[src]
&self,
layout: &str,
node_colors: &[&str],
edge_colors: &[&str]
) -> String
Generates a GraphViz dot format.
pub fn fst_empty(&self) -> Option<(usize, usize)>
[src]
Finds the first empty edge.
pub fn min_colors(&self) -> Option<(usize, usize)>
[src]
Finds the edge with the least possible colors.
pub fn solve(self, solve_settings: SolveSettings) -> Option<Solution<Graph>>
[src]
Solves the graph puzzle using default strategy.
The default strategy is Graph::min_colors, Graph::colors
.
pub fn push(&mut self, node: Node)
[src]
Adds a node description.
pub fn push_pair(&mut self, (i, j): (usize, usize))
[src]
Adds a pair constraint.
pub fn node_satisfied(&self, i: usize) -> Vec<Constraint>
[src]
Returns a list of edge constraints that makes a node unsatisfied.
If the returned list is empty, then the node is satisfied.
pub fn all_satisfied(&self) -> bool
[src]
Returns true
if all nodes are satisfied.
pub fn pairs_satisfied(&self) -> bool
[src]
Returns true
if all pair constraints are satisfied.
pub fn has_triangles(&self) -> bool
[src]
Returns whether the graph contains triangles.
pub fn meet_quad_satisfied(&self) -> bool
[src]
Returns true
when for any node,
the greatest shortest cycle is either 3 or 4.
pub fn is_connected(&self) -> bool
[src]
Returns true
if all nodes can be reached from any node.
pub fn is_upper_right_disconnected(&self) -> bool
[src]
Returns true
if no-edges covers the upper right rectangle of the matrix form.
This means that the graph will be disconnected.
pub fn colors(&self, (i, j): (usize, usize)) -> Vec<Color>
[src]
Returns a list of possible actions for a node.
Trait Implementations
impl Clone for Graph
[src]
impl Debug for Graph
[src]
impl Default for Graph
[src]
impl Puzzle for Graph
[src]
type Pos = (usize, usize)
The type of position.
type Val = Color
The type of values stored in the puzzle.
fn set(&mut self, (i, j): (usize, usize), val: Color)
[src]
fn get(&self, (i, j): (usize, usize)) -> Color
[src]
fn print(&self)
[src]
fn solve_simple<F: FnMut(&mut Self, Self::Pos, Self::Val)>(&mut self, f: F)
[src]
fn is_solved(&self) -> bool
[src]
fn remove(&mut self, other: &Graph)
[src]
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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>,