Skip to content

Commit 7c314af

Browse files
committed
Update documentation
1 parent befb5ee commit 7c314af

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

example_dfs_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ func (d *DFSData) dfsVisit(g graph.Iterator, v int) {
6464
d.Finish[v] = d.Time
6565
}
6666

67-
// An implementation of DFS demonstrating how to use this package.
67+
// An implementation of depth-first search
68+
// demonstrating how to use this package.
6869
func Example_dFS() {
6970
// Build a small directed graph:
7071
//

examples_test.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ func Example_basics() {
1717
g.AddBoth(1, 3)
1818

1919
// The vertices of all graphs in this package are numbered 0..n-1.
20-
// The edge iterator is a method called Visit; it calls
21-
// a do function for each neighbor of a given vertex. Together
22-
// with the Order methodwhich returns the number of vertices
23-
// in a graph—it constitutes an Iterator. All algorithms in this
24-
// package operate on any graph implementing this interface.
20+
// The edge iterator is a method called Visit; it calls a function
21+
// for each neighbor of a given vertex. Together with the Order
22+
// methodwhich returns the number of vertices in a graph — it
23+
// constitutes an Iterator. All algorithms in this package operate
24+
// on any graph implementing this interface.
2525

2626
// Visit all edges of a graph.
2727
for v := 0; v < g.Order(); v++ {
@@ -118,9 +118,8 @@ func ExampleEulerDirected() {
118118
g.AddBoth(0, 1)
119119
g.Add(1, 2)
120120

121-
walk, _ := graph.EulerDirected(g)
122-
fmt.Println(walk)
123-
// Output: [1 0 1 2]
121+
fmt.Println(graph.EulerDirected(g))
122+
// Output: [1 0 1 2] true
124123
}
125124

126125
// Find an Euler walk in an undirected graph.
@@ -135,10 +134,9 @@ func ExampleEulerUndirected() {
135134
g.AddBoth(2, 3)
136135
g.AddBoth(3, 3)
137136

138-
walk, _ := graph.EulerUndirected(g)
139-
fmt.Println(walk)
137+
fmt.Println(graph.EulerUndirected(g))
140138
// Output:
141-
// [1 3 3 2]
139+
// [1 3 3 2] true
142140
}
143141

144142
// Find a shortest path between two vertices in a graph.

graph.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
//
33
// Generic graph algorithms
44
//
5-
// The algorithms can be applied to any graph data structure implementing
6-
// the two Iterator methods: Order, which returns the number of vertices,
7-
// and Visit, which iterates over the neighbors of a vertex.
5+
// The algorithms in this library can be applied to any graph data
6+
// structure implementing the two Iterator methods: Order, which returns
7+
// the number of vertices, and Visit, which iterates over the neighbors
8+
// of a vertex.
89
//
910
// All algorithms operate on directed graphs with a fixed number
1011
// of vertices, labeled from 0 to n-1, and edges with integer cost.
@@ -77,7 +78,7 @@ type edge struct {
7778
}
7879

7980
// String returns a description of g with two elements:
80-
// the number of vertices, followed by a list of all edges.
81+
// the number of vertices, followed by a sorted list of all edges.
8182
func String(g Iterator) string {
8283
n := g.Order()
8384
// This may be a multigraph, so we look for duplicates by counting.

immutable.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ func (g *Immutable) VisitFrom(v int, a int, do func(w int, c int64) bool) bool {
118118
return false
119119
}
120120

121-
// String returns a string representation of this graph.
121+
// String returns a string representation of the graph.
122122
func (g *Immutable) String() string {
123123
return String(g)
124124
}
125125

126-
// Order returns the number of vertices in this graph.
126+
// Order returns the number of vertices in the graph.
127127
func (g *Immutable) Order() int {
128128
return len(g.edges)
129129
}

maxflow.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package graph
22

33
// MaxFlow computes a maximum flow from s to t in a graph
44
// with nonnegative edge capacities.
5-
// The time complexity is O(|V|⋅|E|²), where |V| is the number of vertices
6-
// and |E| the number of edges in the graph.
5+
// The time complexity is O(|E|²⋅|V|), where |E| is the number of edges
6+
// and |V| the number of vertices in the graph.
77
func MaxFlow(g Iterator, s, t int) (flow int64, graph Iterator) {
88
// Edmonds-Karp's algorithm
99
n := g.Order()

mutable.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ func copyImmutable(g *Immutable) *Mutable {
7070
return h
7171
}
7272

73-
// String returns a string representation of this graph.
73+
// String returns a string representation of the graph.
7474
func (g *Mutable) String() string {
7575
return String(g)
7676
}
7777

78-
// Order returns the number of vertices in this graph.
78+
// Order returns the number of vertices in the graph.
7979
func (g *Mutable) Order() int {
8080
return len(g.edges)
8181
}

top.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func TopSort(g Iterator) (order []int, ok bool) {
1010
return
1111
}
1212

13-
// Acyclic returns true if g has no cycles.
13+
// Acyclic tells if g has no cycles.
1414
func Acyclic(g Iterator) bool {
1515
_, acyclic := topsort(g, false)
1616
return acyclic

weak.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package graph
22

3-
// Connected returns true if g has exactly one (weakly) connected component.
3+
// Connected tells if g has exactly one (weakly) connected component.
44
func Connected(g Iterator) bool {
55
_, count := components(g)
66
return count == 1

0 commit comments

Comments
 (0)