MCPcopy Index your code
hub / github.com/coder/coder / canReach

Method canReach

agent/unit/graph.go:142–156  ·  view source on GitHub ↗

canReach checks if there is a path from the start vertex to the end vertex.

(start, end VertexType)

Source from the content-addressed store, hash-verified

140
141// canReach checks if there is a path from the start vertex to the end vertex.
142func (g *Graph[EdgeType, VertexType]) canReach(start, end VertexType) bool {
143 if start == end {
144 return true
145 }
146
147 startID, startExists := g.vertexToID[start]
148 endID, endExists := g.vertexToID[end]
149
150 if !startExists || !endExists {
151 return false
152 }
153
154 // Use gonum's built-in path existence check
155 return topo.PathExistsIn(g.gonumGraph, simple.Node(startID), simple.Node(endID))
156}
157
158// ToDOT exports the graph to DOT format for visualization
159func (g *Graph[EdgeType, VertexType]) ToDOT(name string) (string, error) {

Callers 1

AddEdgeMethod · 0.95

Calls 1

NodeMethod · 0.65

Tested by

no test coverage detected