Exemplo n.º 1
0
func createShortestPathGraph() weighted.EdgeWeightedGraph {
	g := weighted.NewEdgeWeightedGraph(8)
	g.AddDirectedEdge(weighted.NewEdge(4, 5, 0.35))
	g.AddDirectedEdge(weighted.NewEdge(5, 4, 0.35))
	g.AddDirectedEdge(weighted.NewEdge(4, 7, 0.37))
	g.AddDirectedEdge(weighted.NewEdge(5, 7, 0.28))
	g.AddDirectedEdge(weighted.NewEdge(7, 5, 0.28))
	g.AddDirectedEdge(weighted.NewEdge(5, 1, 0.32))
	g.AddDirectedEdge(weighted.NewEdge(0, 4, 0.38))
	g.AddDirectedEdge(weighted.NewEdge(0, 2, 0.26))
	g.AddDirectedEdge(weighted.NewEdge(7, 3, 0.39))
	g.AddDirectedEdge(weighted.NewEdge(1, 3, 0.29))
	g.AddDirectedEdge(weighted.NewEdge(2, 7, 0.34))
	g.AddDirectedEdge(weighted.NewEdge(6, 2, 0.40))
	g.AddDirectedEdge(weighted.NewEdge(3, 6, 0.52))
	g.AddDirectedEdge(weighted.NewEdge(6, 0, 0.58))
	g.AddDirectedEdge(weighted.NewEdge(6, 4, 0.93))

	return g
}
Exemplo n.º 2
0
func createLazyEdgeWeightedGraph() weighted.EdgeWeightedGraph {
	g := weighted.NewEdgeWeightedGraph(8)
	g.AddUndirectedEdge(weighted.NewEdge(4, 5, 0.35))
	g.AddUndirectedEdge(weighted.NewEdge(4, 7, 0.37))
	g.AddUndirectedEdge(weighted.NewEdge(5, 7, 0.28))
	g.AddUndirectedEdge(weighted.NewEdge(0, 7, 0.16))
	g.AddUndirectedEdge(weighted.NewEdge(1, 5, 0.32))
	g.AddUndirectedEdge(weighted.NewEdge(0, 4, 0.38))
	g.AddUndirectedEdge(weighted.NewEdge(2, 3, 0.17))
	g.AddUndirectedEdge(weighted.NewEdge(1, 7, 0.19))
	g.AddUndirectedEdge(weighted.NewEdge(0, 2, 0.26))
	g.AddUndirectedEdge(weighted.NewEdge(1, 2, 0.36))
	g.AddUndirectedEdge(weighted.NewEdge(1, 3, 0.29))
	g.AddUndirectedEdge(weighted.NewEdge(2, 7, 0.34))
	g.AddUndirectedEdge(weighted.NewEdge(6, 2, 0.40))
	g.AddUndirectedEdge(weighted.NewEdge(3, 6, 0.52))
	g.AddUndirectedEdge(weighted.NewEdge(6, 0, 0.58))
	g.AddUndirectedEdge(weighted.NewEdge(6, 4, 0.93))

	return g
}