MCPcopy
hub / github.com/purpleidea/mgmt / AddEdge

Method AddEdge

pgraph/pgraph.go:282–296  ·  view source on GitHub ↗

AddEdge adds a directed edge to the graph from v1 to v2.

(v1, v2 Vertex, e Edge)

Source from the content-addressed store, hash-verified

280
281// AddEdge adds a directed edge to the graph from v1 to v2.
282func (obj *Graph) AddEdge(v1, v2 Vertex, e Edge) {
283 // NOTE: this doesn't allow more than one edge between two vertices...
284 obj.AddVertex(v1, v2) // supports adding N vertices now
285 // TODO: check if an edge exists to avoid overwriting it!
286 // NOTE: VertexMerge() depends on overwriting it at the moment...
287 // NOTE: Interpret() depends on overwriting it at the moment...
288 if obj.adjacency[v1] == nil { // lazily allocated by AddVertex
289 obj.adjacency[v1] = make(map[Vertex]Edge)
290 }
291 obj.adjacency[v1][v2] = e
292 if obj.revadjmap[v2] == nil { // lazily allocated by AddVertex
293 obj.revadjmap[v2] = make(map[Vertex]Edge)
294 }
295 obj.revadjmap[v2][v1] = e
296}
297
298// DeleteEdge uses variadic input to delete all the listed edges from the graph.
299func (obj *Graph) DeleteEdge(xe ...Edge) {

Callers 15

TestGraphSync1Function · 0.95
TestGraphSync2Function · 0.95
TestGraphSync3Function · 0.95
CopyWithFnMethod · 0.95
FilterGraphWithFnMethod · 0.95
TestAddEdgeGraph1Function · 0.95
TestAddEdgeVertexGraph1Function · 0.95
TestAddEdgeGraphVertex1Function · 0.95
buildChainFunction · 0.95
buildFanoutFunction · 0.95

Calls 1

AddVertexMethod · 0.95

Tested by 15

TestGraphSync1Function · 0.76
TestGraphSync2Function · 0.76
TestGraphSync3Function · 0.76
TestAddEdgeGraph1Function · 0.76
TestAddEdgeVertexGraph1Function · 0.76
TestAddEdgeGraphVertex1Function · 0.76
buildChainFunction · 0.76
buildFanoutFunction · 0.76
buildFaninFunction · 0.76
buildLayeredFunction · 0.76