pub struct List<E, Ix = DefaultIx> where
    Ix: IndexType
{ /* private fields */ }
Expand description

An adjacency list with labeled edges.

Can be interpreted as a directed graph with unweighted nodes.

This is the most simple adjacency list you can imagine. Graph, in contrast, maintains both the list of successors and predecessors for each node, which is a different trade-off.

Allows parallel edges and self-loops.

This data structure is append-only (except for clear), so indices returned at some point for a given graph will stay valid with this same graph until it is dropped or clear is called.

Space consumption: O(|E|).

Implementations

Creates a new, empty adjacency list.

Creates a new, empty adjacency list tailored for nodes nodes.

Removes all nodes and edges from the list.

Returns the number of edges in the list

Computes in O(|V|) time.

Adds a new node to the list. This allocates a new Vec and then should run in amortized O(1) time.

Adds a new node to the list. This allocates a new Vec and then should run in amortized O(1) time.

Adds a new node to the list by giving its list of successors and the corresponding weigths.

Add an edge from a to b to the graph, with its associated data weight.

Return the index of the new edge.

Computes in O(1) time.

Panics if the source node does not exist.

Note: List allows adding parallel (“duplicate”) edges. If you want to avoid this, use .update_edge(a, b, weight) instead.

Accesses the source and target of edge e

Computes in O(1)

Lookups whether there is an edge from a to b.

Computes in O(e’) time, where e’ is the number of successors of a.

Lookups whether there is an edge from a to b.

Computes in O(e’) time, where e’ is the number of successors of a.

Returns an iterator over all node indices of the graph.

Consuming the whole iterator take O(|V|).

Returns an iterator over all edge indices of the graph.

Consuming the whole iterator take O(|V| + |E|).

Trait Implementations

Adds a new node to the list. This allocates a new Vec and then should run in amortized O(1) time.

Add an edge from a to b to the graph, with its associated data weight.

Return the index of the new edge.

Computes in O(1) time.

Panics if the source node does not exist.

Note: List allows adding parallel (“duplicate”) edges. If you want to avoid this, use .update_edge(a, b, weight) instead.

Updates or adds an edge from a to b to the graph, with its associated data weight.

Return the index of the new edge.

Computes in O(e’) time, where e’ is the number of successors of a.

Panics if the source node does not exist.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Accesses the weight of edge e

Computes in O(1)

Accesses the weight of edge e

Computes in O(1)

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Returns the number of edges in the list

Computes in O(|V|) time.

The adjacency matrix for List is a bitmap that’s computed by .adjacency_matrix().

The associated adjacency matrix type

Create the adjacency matrix

Return true if there is an edge from a to b, false otherwise. Read more

node identifier

edge identifier

The kind edges in the graph.

Returns an iterator of all nodes with an edge starting from a. Panics if a is out of bounds. Use List::edge_indices_from instead if you do not want to borrow the adjacency list while iterating.

Returns the number of nodes in the list

Computes in O(1) time.

Return an upper bound of the node indices in the graph (suitable for the size of a bitmap). Read more

Convert a to an integer index.

Convert i to a node index. i must be a valid value in the graph.

The associated map type

Create a new visitor map

Reset the visitor map (and resize to new size of graph if needed)

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 resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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.