[][src]Struct graph_solver::Graph

pub struct Graph {
    pub nodes: Vec<Node>,
    pub edges: Vec<Vec<Color>>,
    pub pairs: Vec<(usize, usize)>,
    pub no_triangles: bool,
    pub meet_quad: bool,
    pub connected: bool,
    pub commute_quad: Option<bool>,
    // some fields omitted
}

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.

commute_quad: Option<bool>

Whether commutativity/anticommutativity is enabled for quads.

When a quad commutes, the edges along one dimension have same colors. When a quad anticommutes, the edges along one dimension have same colors, but with an odd number of positive and negative signs (1+3 or 3+1).

It is assumed that even and odd colors for edges above 2 anticommutes, e.g. 2 and 3 anticommutes.

  • When set to Some(true), every quad commutes.
  • When set to Some(false), every quad anticommutes.
  • When set to None

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]

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 commute_quad_satisfied(&self, commute: bool) -> bool[src]

Returns true when for any quad, the commute property is satisfied.

For more information, see Graph::commute.

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.

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.