Skip to content

Commit ff5df92

Browse files
author
Stefan Nilsson
committed
Update documentation
1 parent 7c314af commit ff5df92

File tree

9 files changed

+21
-21
lines changed

9 files changed

+21
-21
lines changed

build/build.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ type Virtual struct {
6868
visit func(v int, a int, do func(w int, c int64) (skip bool)) (aborted bool)
6969
}
7070

71-
// FilterFunc is a function that tells if there is an edge from v to w.
71+
// FilterFunc is a function that tells if there is a directed edge from v to w.
7272
// The nil value represents an edge functions that always returns true.
7373
type FilterFunc func(v, w int) bool
7474

7575
// CostFunc is a function that computes the cost of an edge from v to w.
7676
// The nil value represents a cost function that always returns 0.
7777
type CostFunc func(v, w int) int64
7878

79-
// Cost returns a CostFunc which always returns n.
79+
// Cost returns a CostFunc that always returns n.
8080
func Cost(n int64) CostFunc {
8181
return func(int, int) int64 { return n }
8282
}
@@ -432,7 +432,7 @@ func (g *Virtual) AddCostFunc(c CostFunc) *Virtual {
432432
return &res
433433
}
434434

435-
// Order returns the number of vertices in this graph.
435+
// Order returns the number of vertices in the graph.
436436
func (g *Virtual) Order() int {
437437
return g.order
438438
}

build/cartesian.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package build
22

33
import "strconv"
44

5-
// Cartesian returns the cartesian product of g1 and g2;
5+
// Cartesian returns the cartesian product of g1 and g2:
66
// a graph whose vertices correspond to ordered pairs (v1, v2),
77
// where v1 and v2 are vertices in g1 and g2, respectively.
88
// The vertices (v1, v2) and (w1, w2) are connected by an edge if

build/cycle.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package build
22

3-
// Cycle returns a virtual cycle graph with the edges
4-
// {0, 1}, {1, 2}, {2, 3},... , {n-1, 0}.
3+
// Cycle returns a virtual cycle graph with n vertices and
4+
// the edges {0, 1}, {1, 2}, {2, 3},... , {n-1, 0}.
55
func Cycle(n int) *Virtual {
66
switch {
77
case n < 0:

build/edgeset.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func NoEdges() EdgeSet {
2424
}
2525
}
2626

27-
// Edge returns a set consisting of the single edge {v, w}, where v ≠ w.
27+
// Edge returns a set consisting of a single edge {v, w}, v ≠ w, of zero cost.
2828
func Edge(v, w int) EdgeSet {
2929
if v < 0 || w < 0 || v == w {
3030
return NoEdges()
@@ -35,7 +35,7 @@ func Edge(v, w int) EdgeSet {
3535
}
3636
}
3737

38-
// Contains tells if the set contains the edge from v to w.
38+
// Contains tells if the set contains the edge {v, w}.
3939
func (e EdgeSet) Contains(v, w int) bool {
4040
switch {
4141
case e.Keep != nil && !e.Keep(v, w):

build/examples_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import (
1010
// Find a shortest path going back and forth between
1111
// two sets of points in the plane.
1212
func Example_euclid() {
13-
type point struct{ x, y int }
13+
type Point struct{ x, y int }
1414

1515
// Euclidean distance.
16-
euclid := func(p, q point) float64 {
16+
Euclid := func(p, q Point) float64 {
1717
xd := p.x - q.x
1818
yd := p.y - q.y
1919
return math.Sqrt(float64(xd*xd + yd*yd))
@@ -22,7 +22,7 @@ func Example_euclid() {
2222
// 0 3
2323
// 1 4
2424
// 2 5
25-
points := []point{
25+
points := []Point{
2626
{0, 0}, {0, 1}, {0, 2},
2727
{4, 0}, {4, 1}, {4, 2},
2828
}
@@ -32,7 +32,7 @@ func Example_euclid() {
3232
// and then apply a cost function to the edges of the graph.
3333
g := build.Kmn(3, 3).AddCostFunc(func(v, w int) int64 {
3434
// Distance to three decimal places.
35-
return int64(1000 * euclid(points[v], points[w]))
35+
return int64(1000 * Euclid(points[v], points[w]))
3636
})
3737

3838
// Find a shortest path from 0 to 2.

build/grid.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package build
22

33
import "strconv"
44

5-
// Grid returns a virtual graph whose vertices correspond to points in the plane
6-
// with integer coordinates, y-coordinates being in the range 0..m-1,
7-
// and x-coordinates in the range 0..n-1. Two vertices are connected
8-
// by an edge whenever the corresponding points are at distance 1.
5+
// Grid returns a virtual graph whose vertices correspond to integer
6+
// points in the plane: y-coordinates being in the range 0..m-1,
7+
// and x-coordinates in the range 0..n-1. Two vertices of a grid
8+
// are adjacent whenever the corresponding points are at distance 1.
99
//
1010
// Point (x, y) gets index nx + y, and index i corresponds to the point (i/n, i%n).
1111
func Grid(m, n int) *Virtual {

build/match.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package build
33
// Match connects g1 to g2 by matching vertices in g1 with vertices in g2.
44
// Only vertices belonging to the bridge are included,
55
// and the vertices are matched in numerical order.
6-
// The vertices of g2 are renumbered before the operation:
6+
// The vertices of g2 are renumbered before the matching:
77
// vertex v ∊ g2 becomes v + g1.Order() in the new graph.
88
func (g1 *Virtual) Match(g2 *Virtual, bridge EdgeSet) *Virtual {
99
n := g1.order + g2.order

build/tensor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package build
22

33
import "strconv"
44

5-
// Tensor returns the tensor product of g1 and g2;
5+
// Tensor returns the tensor product of g1 and g2:
66
// a graph whose vertices correspond to ordered pairs (v1, v2),
77
// where v1 and v2 are vertices in g1 and g2, respectively.
88
// The vertices (v1, v2) and (w1, w2) are connected by an edge whenever

build/vertexset.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package build
33
import "sort"
44

55
// VertexSet represents a set of vertices in a graph.
6-
// The zero value of a VertexSet is the universe,
7-
// which represents all vertices in a graph.
6+
// The zero value of a VertexSet is the universe;
7+
// the set containing all vertices.
88
type VertexSet struct {
99
// A set is an immutable sorted list of non-empty disjoint intervals.
1010
// The zero value VertexSet{nil} represents the universe.
@@ -90,7 +90,7 @@ func (s VertexSet) rank(n int) int {
9090
return in.index + n - in.a
9191
}
9292

93-
// Contains tells if v is a member of set s.
93+
// Contains tells if v is a member of the set.
9494
func (s VertexSet) Contains(v int) bool {
9595
switch {
9696
case s.set == nil:

0 commit comments

Comments
 (0)