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

Method GetForwardAdjacentVertices

agent/unit/graph.go:73–96  ·  view source on GitHub ↗

GetForwardAdjacentVertices returns all the edges that originate from the given vertex.

(from VertexType)

Source from the content-addressed store, hash-verified

71
72// GetForwardAdjacentVertices returns all the edges that originate from the given vertex.
73func (g *Graph[EdgeType, VertexType]) GetForwardAdjacentVertices(from VertexType) []Edge[EdgeType, VertexType] {
74 g.mu.RLock()
75 defer g.mu.RUnlock()
76
77 fromID, exists := g.vertexToID[from]
78 if !exists {
79 return []Edge[EdgeType, VertexType]{}
80 }
81
82 edges := []Edge[EdgeType, VertexType]{}
83 toNodes := g.gonumGraph.From(fromID)
84 for toNodes.Next() {
85 toID := toNodes.Node().ID()
86 to := g.idToVertex[toID]
87
88 // Get the edge type
89 edgeKey := fmt.Sprintf("%d->%d", fromID, toID)
90 edgeType := g.edgeTypes[edgeKey]
91
92 edges = append(edges, Edge[EdgeType, VertexType]{From: from, To: to, Edge: edgeType})
93 }
94
95 return edges
96}
97
98// GetReverseAdjacentVertices returns all the edges that terminate at the given vertex.
99func (g *Graph[EdgeType, VertexType]) GetReverseAdjacentVertices(to VertexType) []Edge[EdgeType, VertexType] {

Callers 5

TestGraphFunction · 0.80
TestGraphThreadSafetyFunction · 0.80
GetAllDependenciesMethod · 0.80

Calls 3

NextMethod · 0.65
IDMethod · 0.65
NodeMethod · 0.65

Tested by 3

TestGraphFunction · 0.64
TestGraphThreadSafetyFunction · 0.64