pub struct WeightGraph<T> {
    pub index_map: HashMap<T, NodeIndex>,
    pub graph: UnMatrix<(), BoolIdx>,
}
Expand description

Weight graph provides a wrapper over a Graph that allows adding edges using the NodeWeight type T (petgraph only allows adding edges using NodeIndex). Additionally, the edges are not allowed to have any weights.

The internal representation stores a mapping from NodeWeight T to a NodeIndex in the graph. The underlying petgraph::MatrixGraph stores () for node weights and a boolean to represent the edges.

Fields

index_map: HashMap<T, NodeIndex>

Mapping from T to a unique identifier.

graph: UnMatrix<(), BoolIdx>

Graph representating using identifier.

Implementations

Add an edge between a and b.

Add edges between all given items.

Checks if the node has already been added to the graph.

Add a new node to the graph. Client code should ensure that duplicate edges are never added to graph. Instead of using this method, consider constructing the graph using From<Iterator<T>>.

Panics

(Debug build only) Panics if node is already present in the graph

Returns a Map from NodeIndex to T (the reverse of the index)

Returns an iterator over references to nodes in the Graph.

Return the degree of a given node (number of edges connected).

Trait Implementations

Returns the “default value” for a type. Read more
Converts to this type from the input type.
Converts the given value to a String. 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 the argument unchanged.

Calls U::from(self).

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

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.