Struct blossom::graph::AnnotatedGraph [] [src]

pub struct AnnotatedGraph<Annotation> where
    Annotation: Copy + Sized
{ /* fields omitted */ }

A graph with annotations on edges

Methods

impl<Annotation> AnnotatedGraph<Annotation> where
    Annotation: Copy + Sized
[src]

[src]

Returns a new AnnotatedGraph instance

Arguments

  • edges - HashMap from vertex to edges and their meta data

Remarks

Edges is inherently redundant. It is the responsibility of the caller to guarantee consistency.

Example

use blossom::graph::AnnotatedGraph;
let graph = AnnotatedGraph::new([
  (0, (vec![1, 2], vec![0.1, 0.4])),
  (2, (vec![0], vec![0.4])),
  (1, (vec![0], vec![0.1]))
].iter().cloned().collect());

[src]

Gets a value indicating whether the graph is empty

[src]

Gets the number of vertices in the graph

[src]

Gets the vertices in the graph

[src]

Gets the vertices adjacent to the given vertex

[src]

Gets the edges adjacent to the given vertex

[src]

Creates a new AnnotatedGraph with vertices filtered by given predicate.

[src]

Creates a new AnnotatedGraph with edges filtered by given predicate.

[src]

Determines a maximum matching in the current graph.

Note: the (undirected) edges may be represented in reverse direction from the initial graph construction.

Example

use blossom::Graph;
let graph: Graph = [
  (0, vec![1, 2, 3]),
  (1, vec![0, 2]),
  (2, vec![0, 1]),
  (3, vec![0])
].iter().collect();
let matching = graph.maximum_matching();
let matching_edges = matching.edges();
assert!(!matching_edges.contains(&(0, 1)) && !matching_edges.contains(&(1, 0)));
assert!(matching_edges.contains(&(0, 3)) || matching_edges.contains(&(3, 0)));

[src]

Determines a full matching in the current graph. If a full matching is not possible, None is returned.

Note: the (undirected) edges may be represented in reverse direction from the initial graph construction.

Note 2: in a graph with 2n+1 vertices, a matching consisting of n edges is considered full.

Trait Implementations

impl<Annotation: Clone> Clone for AnnotatedGraph<Annotation> where
    Annotation: Copy + Sized
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<Annotation: Debug> Debug for AnnotatedGraph<Annotation> where
    Annotation: Copy + Sized
[src]

[src]

Formats the value using the given formatter.

impl<Annotation> FromIterator<(Vertex, (Vec<Vertex>, Vec<Annotation>))> for AnnotatedGraph<Annotation> where
    Annotation: Copy + Sized
[src]

[src]

Creates a value from an iterator. Read more

impl<'a, Annotation> FromIterator<&'a (Vertex, (Vec<Vertex>, Vec<Annotation>))> for AnnotatedGraph<Annotation> where
    Annotation: 'a + Copy + Sized
[src]

[src]

Creates a value from an iterator. Read more