Skip to content

Commit be00edb

Browse files
author
root
committed
Add more docs to the Graph type
1 parent 16146ff commit be00edb

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/graph.rs

+16-3
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ impl<E, Ix: IndexType = DefIndex> Edge<E, Ix>
204204
///
205205
/// Based on the graph implementation in rustc.
206206
///
207+
/// ### Graph Indices
208+
///
207209
/// The graph maintains unique indices for nodes and edges, and node and edge
208210
/// weights may be accessed mutably.
209211
///
@@ -213,11 +215,22 @@ impl<E, Ix: IndexType = DefIndex> Edge<E, Ix>
213215
/// all indices stable, but removing a node will force the last node to shift its index to
214216
/// take its place. Similarly, removing an edge shifts the index of the last edge.
215217
///
216-
/// The fact that the node and edge indices in the graph are numbered in a compact interval from
217-
/// 0 to *n* - 1 simplifies some graph algorithms.
218-
///
219218
/// The **Ix** parameter is **u32** by default. The goal is that you can ignore this parameter
220219
/// completely unless you need a very big graph -- then you can use **usize**.
220+
///
221+
/// ### Tradeoffs With Indices
222+
///
223+
/// * The fact that the node and edge indices in the graph are numbered in a compact interval from
224+
/// 0 to *n* - 1 simplifies some graph algorithms.
225+
///
226+
/// * You can select graph index integer type after the size of the graph. A smaller
227+
/// size has better performance due to cache effects.
228+
///
229+
/// * Using indices allows mutation while traversing the graph, see `Dfs`.
230+
///
231+
/// * You can create several graphs using the equal node indices but with
232+
/// differing weights or differing edges.
233+
///
221234
pub struct Graph<N, E, Ty = Directed, Ix: IndexType = DefIndex> {
222235
nodes: Vec<Node<N, Ix>>,
223236
edges: Vec<Edge<E, Ix>>,

0 commit comments

Comments
 (0)