当前位置: 首页>>代码示例>>Golang>>正文


Golang Edge.Tail方法代码示例

本文整理汇总了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
}
开发者ID:cjnygard,项目名称:origin,代码行数:7,代码来源:tilegraph.go

示例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
}
开发者ID:cjnygard,项目名称:origin,代码行数:8,代码来源:mutablegr.go

示例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
}
开发者ID:cjnygard,项目名称:origin,代码行数:8,代码来源:mutdir.go

示例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())
}
开发者ID:cjnygard,项目名称:origin,代码行数:11,代码来源:mutablegr.go

示例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())
}
开发者ID:cjnygard,项目名称:origin,代码行数:11,代码来源:mutdir.go

示例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}
}
开发者ID:cjnygard,项目名称:origin,代码行数:13,代码来源:mutablegr.go

示例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
	}
}
开发者ID:cjnygard,项目名称:origin,代码行数:9,代码来源:dense.go

示例8: Cost

func (g *DenseGraph) Cost(e graph.Edge) float64 {
	return g.adjacencyMatrix[e.Head().ID()*g.numNodes+e.Tail().ID()]
}
开发者ID:cjnygard,项目名称:origin,代码行数:3,代码来源:dense.go


注:本文中的github.com/gonum/graph.Edge.Tail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。