Merge pull request #59 from bluss/minor-changes
Minor changes: docs, small type param default removal
diff --git a/src/graph.rs b/src/graph.rs
index bbc25ac..f51c0bb 100644
--- a/src/graph.rs
+++ b/src/graph.rs
@@ -214,6 +214,10 @@
/// is some local measure of edge count.
/// Based on the graph datastructure used in rustc.
///
+/// Here's an example of building a graph with directed edges, and below
+/// an illustration of how it could be rendered with graphviz (graphviz rendering
+/// is not a part of petgraph):
+///
/// ```
/// use petgraph::Graph;
///
@@ -233,8 +237,9 @@
///
/// ### Graph Indices
///
-/// The graph maintains unique indices for nodes and edges, and node and edge
-/// weights may be accessed mutably.
+/// The graph maintains indices for nodes and edges, and node and edge
+/// weights may be accessed mutably. Indices range in a compact interval, for
+/// example for *n* nodes indices are 0 to *n* - 1 inclusive.
///
/// `NodeIndex` and `EdgeIndex` are types that act as references to nodes and edges,
/// but these are only stable across certain operations.
@@ -246,7 +251,7 @@
/// The `Ix` parameter is `u32` by default. The goal is that you can ignore this parameter
/// completely unless you need a very big graph -- then you can use `usize`.
///
-/// ### Tradeoffs With Indices
+/// ### Pros and Cons of Indices
///
/// * The fact that the node and edge indices in the graph each are numbered in compact
/// intervals (from 0 to *n* - 1 for *n* nodes) simplifies some graph algorithms.
@@ -345,6 +350,9 @@
impl<N, E> Graph<N, E, Directed>
{
/// Create a new `Graph` with directed edges.
+ ///
+ /// This is a convenience method. Use `Graph::with_capacity` or `Graph::default` for
+ /// a constructor that is generic in all the type parameters of `Graph`.
pub fn new() -> Self
{
Graph{nodes: Vec::new(), edges: Vec::new(),
@@ -355,6 +363,9 @@
impl<N, E> Graph<N, E, Undirected>
{
/// Create a new `Graph` with undirected edges.
+ ///
+ /// This is a convenience method. Use `Graph::with_capacity` or `Graph::default` for
+ /// a constructor that is generic in all the type parameters of `Graph`.
pub fn new_undirected() -> Self
{
Graph{nodes: Vec::new(), edges: Vec::new(),
@@ -362,7 +373,7 @@
}
}
-impl<N, E, Ty=Directed, Ix=DefIndex> Graph<N, E, Ty, Ix>
+impl<N, E, Ty, Ix> Graph<N, E, Ty, Ix>
where Ty: EdgeType,
Ix: IndexType,
{
@@ -1094,9 +1105,11 @@
}
- /// Create a new `Graph` by mapping node and edge weights.
+ /// Create a new `Graph` by mapping node and
+ /// edge weights to new values.
///
- /// The resulting graph has the same graph indices as `self`.
+ /// The resulting graph has the same structure and the same
+ /// graph indices as `self`.
pub fn map<'a, F, G, N2, E2>(&'a self, mut node_map: F, mut edge_map: G)
-> Graph<N2, E2, Ty, Ix>
where F: FnMut(NodeIndex<Ix>, &'a N) -> N2,
@@ -1127,6 +1140,7 @@
/// `edge_map` is called for the edges that have not had any endpoint
/// removed.
///
+ /// The resulting graph has the structure of a subgraph of the original graph.
/// If no nodes are removed, the resulting graph has compatible node
/// indices; if neither nodes nor edges are removed, the result has
/// the same graph indices as `self`.
diff --git a/src/stable.rs b/src/stable.rs
index 04d4455..35d58b1 100644
--- a/src/stable.rs
+++ b/src/stable.rs
@@ -90,12 +90,16 @@
impl<N, E> StableGraph<N, E, Directed> {
/// Create a new `StableGraph` with directed edges.
+ ///
+ /// This is a convenience method. See `StableGraph::with_capacity`
+ /// or `StableGraph::default` for a constructor that is generic in all the
+ /// type parameters of `StableGraph`.
pub fn new() -> Self {
Self::with_capacity(0, 0)
}
}
-impl<N, E, Ty=Directed, Ix=DefIndex> StableGraph<N, E, Ty, Ix>
+impl<N, E, Ty, Ix> StableGraph<N, E, Ty, Ix>
where Ty: EdgeType,
Ix: IndexType,
{