Struct blossom::graph::Graph [] [src]

pub struct Graph { /* fields omitted */ }

An undirected graph

Methods

impl Graph
[src]

Returns a person with the name given them

Arguments

  • vertices - All vertices
  • edges - All edges; undirected edges should be specified once, it suffices to specify one direction

Example

use blossom::graph::Graph;
let graph = Graph::new(&[0, 1, 2], &[(0, 1), (1, 2)]);

Returns a value indicating whether the graph is empty, i.e. whether is has no vertices.

Returns the number of vertices in the graph.

Exports all vertices in a vector.

Gets a slice of all vertices connected to the given vertex. Panics if graph does not contain a vertex vertex.

Arguments

  • vertex - The start vertex

Gets all exposed vertices with respect to the given matching.

Arguments

  • matching - Some matching - possibly not maximum - in this graph.

Creates a new graph with all vertices in leafs contracted into root.

Arguments

  • root - Root vertex - will reappear in resulting graph.
  • leafs - Leaf vertices - will not reappear in resulting graph.

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::Graph;
let graph = Graph::new(&[0, 1, 2, 3], &[(0, 1), (0, 2), (0, 3), (1, 2)]);
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)));

Trait Implementations

impl Clone for Graph
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Graph
[src]

Formats the value using the given formatter.