本文整理汇总了Golang中github.com/gonum/graph.Edge.To方法的典型用法代码示例。如果您正苦于以下问题:Golang Edge.To方法的具体用法?Golang Edge.To怎么用?Golang Edge.To使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/gonum/graph.Edge
的用法示例。
在下文中一共展示了Edge.To方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Weight
func (g *TileGraph) Weight(e graph.Edge) float64 {
if edge := g.EdgeBetween(e.From(), e.To()); edge != nil {
return 1
}
return inf
}
示例2: RemoveEdge
// RemoveEdge removes the edge between nodes identified by e.From and e.To and
// its adjacent faces from g.
func (g *Graph) RemoveEdge(e graph.Edge) {
h := g.Halfedge(e.From(), e.To())
if h == nil {
// Nothing to do.
return
}
// Remove any adjacent faces.
if h.Face() != nil {
g.RemoveFace(h.Face())
}
if h.Twin().Face() != nil {
g.RemoveFace(h.Twin().Face())
}
// Detach both halfedges from their From nodes and update affected
// halfedges.
detach(h)
detach(h.Twin())
id := h.Edge().ID()
delete(g.edges, id)
if g.nextEdgeID != 0 && id == g.nextEdgeID {
g.nextEdgeID--
}
g.freeEdges[id] = struct{}{}
}
示例3: Weight
func (g *Graph) Weight(e graph.Edge) float64 {
if n, ok := g.neighbors[e.From().ID()]; ok {
if we, ok := n[e.To().ID()]; ok {
return we.Cost
}
}
return inf
}
示例4: SetEdgeWeight
func (g *DirectedDenseGraph) SetEdgeWeight(e graph.Edge) {
fid := e.From().ID()
tid := e.To().ID()
if fid == tid {
panic("concrete: set edge cost of illegal edge")
}
g.mat.Set(fid, tid, e.Weight())
}
示例5: SetEdge
// SetEdge sets e, an edge from one node to another. If the ends of the edge are not in g
// or the edge is a self loop, SetEdge panics.
func (g *DirectedMatrix) SetEdge(e graph.Edge) {
fid := e.From().ID()
tid := e.To().ID()
if fid == tid {
panic("simple: set illegal edge")
}
g.mat.Set(fid, tid, e.Weight())
}
示例6: SetEdgeWeight
func (g *UndirectedDenseGraph) SetEdgeWeight(e graph.Edge, weight float64) {
fid := e.From().ID()
tid := e.To().ID()
if fid == tid {
panic("concrete: set edge cost of illegal edge")
}
g.mat.SetSym(fid, tid, weight)
}
示例7: Weight
func (g *DirectedGraph) Weight(e graph.Edge) float64 {
if s, ok := g.successors[e.From().ID()]; ok {
if we, ok := s[e.To().ID()]; ok {
return we.Cost
}
}
return inf
}
示例8: RemoveEdge
func (g *UndirectedGraph) RemoveEdge(e graph.Edge) {
from, to := e.From(), e.To()
if _, ok := g.nodeMap[from.ID()]; !ok {
return
} else if _, ok := g.nodeMap[to.ID()]; !ok {
return
}
delete(g.neighbors[from.ID()], to.ID())
delete(g.neighbors[to.ID()], from.ID())
}
示例9: SetEdge
func (g *gnDirected) SetEdge(e graph.Edge) {
switch {
case e.From().ID() == e.To().ID():
g.addSelfLoop = true
return
case g.DirectedBuilder.HasEdgeFromTo(e.From(), e.To()):
g.addMultipleEdge = true
}
g.DirectedBuilder.SetEdge(e)
}
示例10: RemoveEdge
// RemoveEdge removes e from the graph, leaving the terminal nodes. If the edge does not exist
// it is a no-op.
func (g *DirectedMatrix) RemoveEdge(e graph.Edge) {
fid := e.From().ID()
if !g.has(fid) {
return
}
tid := e.To().ID()
if !g.has(tid) {
return
}
g.mat.Set(fid, tid, g.absent)
}
示例11: Weight
// Weight returns the weight of the given edge.
func (g *Grid) Weight(e graph.Edge) float64 {
if e := g.EdgeBetween(e.From(), e.To()); e != nil {
if !g.AllowDiagonal {
return 1
}
ux, uy := g.XY(e.From())
vx, vy := g.XY(e.To())
return math.Hypot(ux-vx, uy-vy)
}
return math.Inf(1)
}
示例12: RemoveEdge
// RemoveEdge removes e from the graph, leaving the terminal nodes. If the edge does not exist
// it is a no-op.
func (g *DirectedGraph) RemoveEdge(e graph.Edge) {
from, to := e.From(), e.To()
if _, ok := g.nodes[from.ID()]; !ok {
return
}
if _, ok := g.nodes[to.ID()]; !ok {
return
}
delete(g.from[from.ID()], to.ID())
delete(g.to[to.ID()], from.ID())
}
示例13: SetEdge
// SetEdge adds e, an edge from one node to another. If the nodes do not exist, they are added.
// It will panic if the IDs of the e.From and e.To are equal.
func (g *UndirectedGraph) SetEdge(e graph.Edge) {
var (
from = e.From()
fid = from.ID()
to = e.To()
tid = to.ID()
)
if fid == tid {
panic("simple: adding self edge")
}
if !g.Has(from) {
g.AddNode(from)
}
if !g.Has(to) {
g.AddNode(to)
}
g.edges[fid][tid] = e
g.edges[tid][fid] = e
}
示例14: SetEdge
func (g *DirectedGraph) SetEdge(e graph.Edge, cost float64) {
var (
from = e.From()
fid = from.ID()
to = e.To()
tid = to.ID()
)
if fid == tid {
panic("concrete: adding self edge")
}
if !g.Has(from) {
g.AddNode(from)
}
if !g.Has(to) {
g.AddNode(to)
}
g.successors[fid][tid] = WeightedEdge{Edge: e, Cost: cost}
g.predecessors[tid][fid] = WeightedEdge{Edge: e, Cost: cost}
}
示例15: RemoveEdge
func (g *DirectedDenseGraph) RemoveEdge(e graph.Edge) {
g.mat.Set(e.From().ID(), e.To().ID(), g.absent)
}