Skip to content

Commit 5b2420d

Browse files
committed
The 'Simple' property now constains directedness and edge weight.
1 parent 15a6d9a commit 5b2420d

File tree

8 files changed

+10
-15
lines changed

8 files changed

+10
-15
lines changed

src/algo/dfs.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ use std::borrow::Borrow;
7474
///
7575
/// 2. Referenced closure: If Dfs takes a reference to a closure, it no longer
7676
/// needs to be generic on the closures type. However, it limits where Dfs can
77-
/// be used, since its now bound by the lifetime of the reference. It also
77+
/// be used, since it's now bound by the lifetime of the reference. It also
7878
/// doesn't solve the issue with other struct using Dfs, because you can't have
7979
/// the closure anywhere when not using the Dfs.
8080
///
@@ -269,19 +269,19 @@ where
269269
{
270270
// The meaning of markers:
271271
//
272-
// If its on the stack it means we are still visiting it or its children.
272+
// If it's on the stack it means we are still visiting it or its children.
273273
//
274274
// If its exit marked, it means when we are finished visiting it and its
275275
// children, we will call the 'on_exit' closure on it, and then pop it.
276-
// If its not exit marked, it means this instance of it on the stack was
276+
// If it's not exit marked, it means this instance of it on the stack was
277277
// never used for visiting this vertex's children and we just pop it, without
278278
// calling the closure.
279279
//
280280
// If it is marked visited it means we are either visiting its children, or
281281
// we are finished doing so. Either way, it shouldn't go on the stack again
282282
// at any point.
283283

284-
// Pop any vertices that we are done visiting (and since its on the top of the
284+
// Pop any vertices that we are done visiting (and since it's on the top of the
285285
// stack, we must be done visiting its children).
286286
while self.advance_next_exit().is_some()
287287
{}

src/core/ensure.rs

-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ where
138138
/// graph is therefore the first layer. Each layer may need a payload. For
139139
/// example, an ensurer guaranteeing that a given vertex exists may have the
140140
/// vertex as a payload.
141-
///
142141
pub trait ReleasePayload: Sized + GraphDeref
143142
{
144143
/// The base graph implementation being ensured

src/core/property/directedness_ensurers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<C: Ensure> Graph for DirectedGraph<C>
4545
}
4646

4747
impl_ensurer! {
48-
use<C> DirectedGraph<C>: Ensure, Graph, DirectedConstraint
48+
use<C> DirectedGraph<C>: Ensure, Graph, DirectedConstraint, Simple
4949
as (self.0) : C
5050
}
5151

src/core/property/rooted.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub trait Rooted: HasVertex
3737
}
3838
}
3939

40-
/// Ensures the a specific vertex is the root of the graph.
40+
/// Ensures a specific vertex is the root of the graph.
4141
pub struct RootedGraph<C: Ensure>(VertexInGraph<C>);
4242

4343
impl<C: Ensure> Clone for RootedGraph<C>

src/core/property/simple.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use duplicate::duplicate_item;
66
use std::borrow::Borrow;
77

88
/// A marker trait for [simple graphs](https://mathworld.wolfram.com/SimpleGraph.html)
9-
pub trait Simple: NoLoops + Unique {}
9+
pub trait Simple: Graph<EdgeWeight = (), Directedness = Undirected> + NoLoops + Unique {}
1010

1111
#[derive(Clone, Debug)]
1212
pub struct SimpleGraph<C: Ensure>(C);

src/core/property/unilateral.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ use std::borrow::Borrow;
2121
/// directed graphs, for undirected ones, they are equal. For this reason, the
2222
/// companion ensurer graph `UnilateralGraph` only allows directed graphs.
2323
/// For undirected graph, simply use `ConnectedGraph`.
24-
///
25-
/// For type safety reasons, the trait itself does not restrict directedness.
2624
pub trait Unilateral: Weak {}
2725

2826
#[derive(Clone, Debug)]
@@ -106,7 +104,7 @@ impl<C: Ensure> Weak for UnilateralGraph<C> where C::Graph: Graph<Directedness =
106104
impl<C: Ensure> Unilateral for UnilateralGraph<C> where C::Graph: Graph<Directedness = Directed> {}
107105

108106
impl_ensurer! {
109-
use<C> UnilateralGraph<C>: Ensure, Unilateral, Weak, RemoveVertex, RemoveEdge,
107+
use<C> UnilateralGraph<C>: Ensure, Unilateral, Weak, RemoveVertex, RemoveEdge, Simple,
110108
// A new vertex would be unconnected to the rest of the graph
111109
NewVertex
112110
as (self.0) : C

src/core/property/weak.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ use std::borrow::Borrow;
1717
/// directed graphs, for undirected ones, they are equal. For this reason, the
1818
/// companion ensurer graph `WeakGraph` only allows directed graphs. For
1919
/// undirected graph, simply use `ConnectedGraph`.
20-
///
21-
/// For type safety reasons, the trait itself does not restrict directedness.
2220
pub trait Weak: Graph {}
2321

2422
#[derive(Clone, Debug)]
@@ -91,7 +89,7 @@ where
9189
impl<C: Ensure> Weak for WeakGraph<C> where C::Graph: Graph<Directedness = Directed> {}
9290

9391
impl_ensurer! {
94-
use<C> WeakGraph<C>: Ensure, Weak, RemoveVertex, RemoveEdge,
92+
use<C> WeakGraph<C>: Ensure, Weak, RemoveVertex, RemoveEdge, Simple,
9593
// A new vertex wouldn't be connected to the rest of the graph
9694
NewVertex
9795
as (self.0) : C

src/core/proxy/edge_weight_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl<C: Ensure, Ew> Graph for EdgeWeightMap<C, Ew>
9494
}
9595

9696
impl_ensurer! {
97-
use<C,Ew> EdgeWeightMap<C, Ew>: Ensure, Graph, GraphMut, Reflexive, AddEdge, RemoveEdge
97+
use<C,Ew> EdgeWeightMap<C, Ew>: Ensure, Graph, GraphMut, Reflexive, AddEdge, RemoveEdge, Simple
9898
as (self.0) : C
9999
as (self.1) : fn(
100100
<C::Graph as Graph>::Vertex,

0 commit comments

Comments
 (0)