pub struct EditGraph { /* private fields */ }
Expand description

An implementation of the MutableGraph trait with additional convenient editing and generating functions.

Implementations

Generates a path on n vertices.

Generates a cycle on n vertices.

Generates a matching on 2n vertices.

Generates a star with n leaves, so n+1 vertices total.

Generates a complete graph (clique) on n vertices.

Generates an empty graph (independent set) on n vertices.

Generates a complete bipartite graph (biclique) on s+t vertices.

Generates a complete k-partite graph.

Arguments
  • sizes - The sizes of each partite set as a sequence of integers.

Creates a new graph that is the disjoint union of self and graph. The vertices of the second graph are relabelled to avoid index clashes.

Computes the disjoint unions of all graphs in the iterator it.

Creates a copy of the graph in which vertices are labelled from $0$ to $n-1$, where $n$ is the number of vertices in the graph. The relative order of the indices is preserved, e.g. the smallest vertex from the original graph will be labelled $0$ and the largest one $n-1$.

Returns a tuple (graph, map) where graph is the relabelled graph and map stores the mapping from new vertices to old vertices.

Contracts all vertices into the first vertex of the sequence. The contracted vertex has as its neighbours all vertices that were adjacent to at least one vertex in vertices.

This function panics if the sequence is empty.

Returns the contracted vertex.

Contracts the pair ${u,v}$ be identifying $v$ with $u$. The operation removes $v$ from the graph and adds $v$’s neighbours to $u$.

Panics if either of the two vertices does not exist.

Contracts all vertices into the center vertex. The contracted vertex has as its neighbours all vertices that were adjacent to at least one vertex in vertices.

I/O operations for EditGraph defined in crate::io

Loads the graph from a text file which contains edges separated by line breaks. Edges must be pairs of integers separated by a space.

For example, assume the file edges.txt contains the following:

0 1
0 2
0 3

We can then load the file as follows:

use graphbench::graph::*;
use graphbench::editgraph::EditGraph;
use graphbench::iterators::EdgeIterable;
 
fn main() {
    let graph = EditGraph::from_txt("edges.txt").expect("Could not open edges.txt");
    println!("Vertices: {:?}", graph.vertices().collect::<Vec<&Vertex>>());
    println!("Edges: {:?}", graph.edges().collect::<Vec<Edge>>());
}

Loads the graph from a gzipped text file which otherwise follows the format described in EditGraph::from_txt.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Creates a value from an iterator. Read more
Returns the number of vertices in the graph.
Returns the number of edges in the graph.
Returns whether vertices u and v are connected by an edge.
Returns the number of edges incident to u in the graph.
Returns whether the vertex u is contained in the graph.
Returns an iterator to this graph’s vertices.
Returns an iterator over the neighbours of u.
Returns the degrees of all vertices in the graph as a map.
Alias for Graph::num_vertices()
Returns true if the graph contains no vertices
Given an iterator vertices over vertices, returns all vertices of the graph which are neighbours of those vertices but not part of vertices themselves. Read more
Given an iterator vertices over vertices, returns all vertices of the graph which are neighbours of those vertices as well as all vertices contained in vertices. Read more
Returns all vertices which lie within distance at most r to u.
Given an iterator vertices over vertices and a distance r, returns all vertices of the graph which are within distance at most r to vertices contained in vertices. Read more
Returns the subgraph induced by the vertices contained in vertices.
Creates an emtpy mutable graph.
Creates a mutable graph with a hint on how many vertices it will probably contain.
Adds the vertex u to the graph. Read more
Adds the edge uv to the graph. Read more
Removes the edge uv from the graph. Read more
Removes the vertex u from the graph. Read more
Adds a collection of vertices to the graph. Read more
Adds a collection of edges to the graph. Read more
Removes all loops from the graph. Read more
Removes all isolate vertices, that is, vertices without any neighbours. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Returns an EdgeIterator over the edges of this graph.

Returns the argument unchanged.

Returns the connected components of this graph.
Computes the degeneracy (approximate), core-numbers and a degeneracy-ordering of this graph. The return value contains four values: Read more
Tests whether the graph is bipartite and returns a witness.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Returns an EdgeIterator over the edges of this graph.
Returns a NeighIterator for the graph.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.