pgraph: Remove NewVertex and NewEdge methods and fix examples
Since the pgraph graph can store arbitrary pointers, we don't need a special method to create the vertices or edges as long as they implement the String() string method. This cleans up the library and some of the examples which I let rot previously.
This commit is contained in:
@@ -145,7 +145,7 @@ func (c *GraphConfig) NewGraphFromConfig(hostname string, world resources.World,
|
||||
return nil, errwrap.Wrapf(err, "could not VertexMatchFn() resource")
|
||||
}
|
||||
if v == nil { // no match found
|
||||
v = pgraph.NewVertex(res)
|
||||
v = res // a standalone res can be a vertex
|
||||
graph.AddVertex(v) // call standalone in case not part of an edge
|
||||
}
|
||||
lookup[kind][res.GetName()] = v // used for constructing edges
|
||||
@@ -223,7 +223,7 @@ func (c *GraphConfig) NewGraphFromConfig(hostname string, world resources.World,
|
||||
return nil, errwrap.Wrapf(err, "could not VertexMatchFn() resource")
|
||||
}
|
||||
if v == nil { // no match found
|
||||
v = pgraph.NewVertex(res)
|
||||
v = res // a standalone res can be a vertex
|
||||
graph.AddVertex(v) // call standalone in case not part of an edge
|
||||
}
|
||||
lookup[kind][res.GetName()] = v // used for constructing edges
|
||||
|
||||
Reference in New Issue
Block a user