[tools] cmd/digraph: implement graph.Graph interface

4 views
Skip to first unread message

Austin Clements (Gerrit)

unread,
Feb 19, 2026, 6:54:06 PM (5 days ago) Feb 19
to Alan Donovan, goph...@pubsubhelper.golang.org, Austin Clements, golang-co...@googlegroups.com
Attention needed from Alan Donovan

Austin Clements has uploaded the change for review

Austin Clements would like Alan Donovan to review this change.

Commit message

cmd/digraph: implement graph.Graph interface
Change-Id: I2050c2cebd6ea0c9d6412e5219ea690bf7234cb9

Change diff

diff --git a/cmd/digraph/digraph.go b/cmd/digraph/digraph.go
index 3f9c767..1086fc5 100644
--- a/cmd/digraph/digraph.go
+++ b/cmd/digraph/digraph.go
@@ -17,12 +17,18 @@
"flag"
"fmt"
"io"
+ "maps"
"os"
+ "slices"
"sort"
"strconv"
"strings"
"unicode"
"unicode/utf8"
+
+ "iter"
+
+ "golang.org/x/tools/internal/graph"
)

func usage() {
@@ -89,6 +95,17 @@
// A digraph maps nodes to the non-nil set of their immediate successors.
type digraph map[string]nodeset

+func (g digraph) All() iter.Seq[string] {
+ return slices.Values(slices.Sorted(maps.Keys(g)))
+}
+
+func (g digraph) Out(node string) iter.Seq2[int, string] {
+ // Out must be deterministic.
+ return slices.All(slices.Sorted(maps.Keys(g[node])))
+}
+
+var _ graph.Graph[string] = digraph{}
+
func (g digraph) addNode(node string) nodeset {
edges := g[node]
if edges == nil {
@@ -107,11 +124,7 @@
}

func (g digraph) nodelist() nodelist {
- nodes := make(nodeset)
- for node := range g {
- nodes[node] = true
- }
- return nodes.sort()
+ return nodelist(slices.Collect(g.All()))
}

func (g digraph) reachableFrom(roots nodeset) nodeset {

Change information

Files:
  • M cmd/digraph/digraph.go
Change size: S
Delta: 1 file changed, 18 insertions(+), 5 deletions(-)
Open in Gerrit

Related details

Attention is currently required from:
  • Alan Donovan
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I2050c2cebd6ea0c9d6412e5219ea690bf7234cb9
Gerrit-Change-Number: 747363
Gerrit-PatchSet: 1
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Attention: Alan Donovan <adon...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Alan Donovan (Gerrit)

unread,
Feb 23, 2026, 2:39:24 PM (2 days ago) Feb 23
to Austin Clements, goph...@pubsubhelper.golang.org, Go LUCI, golang-co...@googlegroups.com
Attention needed from Austin Clements

Alan Donovan voted and added 1 comment

Votes added by Alan Donovan

Code-Review+2

1 comment

File cmd/digraph/digraph.go
Line 28, Patchset 1 (Latest):
Alan Donovan . unresolved

delete

Open in Gerrit

Related details

Attention is currently required from:
  • Austin Clements
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
  • requirement satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I2050c2cebd6ea0c9d6412e5219ea690bf7234cb9
Gerrit-Change-Number: 747363
Gerrit-PatchSet: 1
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Attention: Austin Clements <aus...@google.com>
Gerrit-Comment-Date: Mon, 23 Feb 2026 19:39:18 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Austin Clements (Gerrit)

unread,
Feb 24, 2026, 10:03:24 PM (7 hours ago) Feb 24
to Austin Clements, goph...@pubsubhelper.golang.org, Alan Donovan, Go LUCI, golang-co...@googlegroups.com

Austin Clements added 1 comment

File cmd/digraph/digraph.go
Line 28, Patchset 1:
Alan Donovan . resolved

delete

Austin Clements

I wonder how I managed that.

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I2050c2cebd6ea0c9d6412e5219ea690bf7234cb9
Gerrit-Change-Number: 747363
Gerrit-PatchSet: 2
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Comment-Date: Wed, 25 Feb 2026 03:03:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Alan Donovan <adon...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Austin Clements (Gerrit)

unread,
Feb 24, 2026, 10:03:26 PM (7 hours ago) Feb 24
to Austin Clements, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Austin Clements uploaded new patchset

Austin Clements uploaded patch set #2 to this change.
Following approvals got outdated and were removed:
  • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newpatchset
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages