本文整理汇总了Golang中github.com/gonum/graph.Edge.Tail方法的典型用法代码示例。如果您正苦于以下问题:Golang Edge.Tail方法的具体用法?Golang Edge.Tail怎么用?Golang Edge.Tail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/gonum/graph.Edge
的用法示例。
在下文中一共展示了Edge.Tail方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Cost
func (g *TileGraph) Cost(e graph.Edge) float64 {
if edge := g.EdgeBetween(e.Head(), e.Tail()); edge != nil {
return 1
}
return inf
}
示例2: Cost
func (g *Graph) Cost(e graph.Edge) float64 {
if n, ok := g.neighbors[e.Head().ID()]; ok {
if we, ok := n[e.Tail().ID()]; ok {
return we.Cost
}
}
return inf
}
示例3: Cost
func (g *DirectedGraph) Cost(e graph.Edge) float64 {
if s, ok := g.successors[e.Head().ID()]; ok {
if we, ok := s[e.Tail().ID()]; ok {
return we.Cost
}
}
return inf
}
示例4: RemoveUndirectedEdge
func (g *Graph) RemoveUndirectedEdge(e graph.Edge) {
head, tail := e.Head(), e.Tail()
if _, ok := g.nodeMap[head.ID()]; !ok {
return
} else if _, ok := g.nodeMap[tail.ID()]; !ok {
return
}
delete(g.neighbors[head.ID()], tail.ID())
delete(g.neighbors[tail.ID()], head.ID())
}
示例5: RemoveDirectedEdge
func (g *DirectedGraph) RemoveDirectedEdge(e graph.Edge) {
head, tail := e.Head(), e.Tail()
if _, ok := g.nodeMap[head.ID()]; !ok {
return
} else if _, ok := g.nodeMap[tail.ID()]; !ok {
return
}
delete(g.successors[head.ID()], tail.ID())
delete(g.predecessors[tail.ID()], head.ID())
}
示例6: AddUndirectedEdge
func (g *Graph) AddUndirectedEdge(e graph.Edge, cost float64) {
head, tail := e.Head(), e.Tail()
if !g.NodeExists(head) {
g.AddNode(head)
}
if !g.NodeExists(tail) {
g.AddNode(tail)
}
g.neighbors[head.ID()][tail.ID()] = WeightedEdge{Edge: e, Cost: cost}
g.neighbors[tail.ID()][head.ID()] = WeightedEdge{Edge: e, Cost: cost}
}
示例7: SetEdgeCost
// Sets the cost of an edge. If the cost is +Inf, it will remove the edge,
// if directed is true, it will only remove the edge one way. If it's false it will change the cost
// of the edge from succ to node as well.
func (g *DenseGraph) SetEdgeCost(e graph.Edge, cost float64, directed bool) {
g.adjacencyMatrix[e.Head().ID()*g.numNodes+e.Tail().ID()] = cost
if !directed {
g.adjacencyMatrix[e.Tail().ID()*g.numNodes+e.Head().ID()] = cost
}
}
示例8: Cost
func (g *DenseGraph) Cost(e graph.Edge) float64 {
return g.adjacencyMatrix[e.Head().ID()*g.numNodes+e.Tail().ID()]
}