graph,graph/{community,network,path}: rename WeightedGraph => Weighted
MODIFY
graph/community/louvain_common.go
graph/community/louvain_common.go
@@ -358,7 +358,7 @@ const (
// positiveWeightFuncFor returns a constructed weight function for the
// positively weighted g.
func positiveWeightFuncFor(g graph.Graph) func(x, y graph.Node) float64 {
- if wg, ok := g.(graph.WeightedGraph); ok {
+ if wg, ok := g.(graph.Weighted); ok {
return func(x, y graph.Node) float64 {
w, ok := wg.Weight(x, y)
if !ok {
@@ -386,7 +386,7 @@ func positiveWeightFuncFor(g graph.Graph) func(x, y graph.Node) float64 {
// negativeWeightFuncFor returns a constructed weight function for the
// negatively weighted g.
func negativeWeightFuncFor(g graph.Graph) func(x, y graph.Node) float64 {
- if wg, ok := g.(graph.WeightedGraph); ok {
+ if wg, ok := g.(graph.Weighted); ok {
return func(x, y graph.Node) float64 {
w, ok := wg.Weight(x, y)
if !ok {

MODIFY
graph/graph.go
graph/graph.go
@@ -45,8 +45,8 @@ type Graph interface {
Edge(u, v Node) Edge
}
-// WeightedGraph is a weighted graph.
-type WeightedGraph interface {
+// Weighted is a weighted graph.
+type Weighted interface {
Graph
// WeightedEdge returns the weighted edge from u to v if
@@ -76,7 +76,7 @@ type Undirected interface {
// WeightedUndirected is a weighted undirected graph.
type WeightedUndirected interface {
- WeightedGraph
+ Weighted
// WeightedEdgeBetween returns the edge between nodes
// x and y.
@@ -98,7 +98,7 @@ type Directed interface {
// WeightedDirected is a weighted directed graph.
type WeightedDirected interface {
- WeightedGraph
+ Weighted
// HasEdgeFromTo returns whether an edge exists
// in the graph from u to v.

MODIFY
graph/network/betweenness.go
graph/network/betweenness.go
@@ -146,7 +146,7 @@ func brandes(g graph.Graph, accumulate func(s graph.Node, stack linear.NodeStack
//
// where \sigma_{st} and \sigma_{st}(v) are the number of shortest paths from s to t,
// and the subset of those paths containing v respectively.
-func BetweennessWeighted(g graph.WeightedGraph, p path.AllShortest) map[int64]float64 {
+func BetweennessWeighted(g graph.Weighted, p path.AllShortest) map[int64]float64 {
cb := make(map[int64]float64)
nodes := g.Nodes()
@@ -197,7 +197,7 @@ func BetweennessWeighted(g graph.WeightedGraph, p path.AllShortest) map[int64]fl
//
// If g is undirected, edges are retained such that u.ID < v.ID where u and v are
// the nodes of e.
-func EdgeBetweennessWeighted(g graph.WeightedGraph, p path.AllShortest) map[[2]int64]float64 {
+func EdgeBetweennessWeighted(g graph.Weighted, p path.AllShortest) map[[2]int64]float64 {
cb := make(map[[2]int64]float64)
_, isUndirected := g.(graph.Undirected)

MODIFY
graph/path/a_star.go
graph/path/a_star.go
@@ -28,7 +28,7 @@ func AStar(s, t graph.Node, g graph.Graph, h Heuristic) (path Shortest, expanded
return Shortest{from: s}, 0
}
var weight Weighting
- if wg, ok := g.(graph.WeightedGraph); ok {
+ if wg, ok := g.(graph.Weighted); ok {
weight = wg.Weight
} else {
weight = UniformCost(g)

MODIFY
graph/path/bellman_ford_moore.go
graph/path/bellman_ford_moore.go
@@ -16,7 +16,7 @@ func BellmanFordFrom(u graph.Node, g graph.Graph) (path Shortest, ok bool) {
return Shortest{from: u}, true
}
var weight Weighting
- if wg, ok := g.(graph.WeightedGraph); ok {
+ if wg, ok := g.(graph.Weighted); ok {
weight = wg.Weight
} else {
weight = UniformCost(g)

MODIFY
graph/path/dijkstra.go
graph/path/dijkstra.go
@@ -20,7 +20,7 @@ func DijkstraFrom(u graph.Node, g graph.Graph) Shortest {
return Shortest{from: u}
}
var weight Weighting
- if wg, ok := g.(graph.WeightedGraph); ok {
+ if wg, ok := g.(graph.Weighted); ok {
weight = wg.Weight
} else {
weight = UniformCost(g)
@@ -83,7 +83,7 @@ func DijkstraAllPaths(g graph.Graph) (paths AllShortest) {
// result of the work in the paths parameter which is a reference type.
func dijkstraAllPaths(g graph.Graph, paths AllShortest) {
var weight Weighting
- if wg, ok := g.(graph.WeightedGraph); ok {
+ if wg, ok := g.(graph.Weighted); ok {
weight = wg.Weight
} else {
weight = UniformCost(g)

MODIFY
graph/path/dynamic/dstarlite.go
graph/path/dynamic/dstarlite.go
@@ -73,7 +73,7 @@ func NewDStarLite(s, t graph.Node, g graph.Graph, h path.Heuristic, m WorldModel
*/
d.last = d.s
- if wg, ok := g.(graph.WeightedGraph); ok {
+ if wg, ok := g.(graph.Weighted); ok {
d.weight = wg.Weight
} else {
d.weight = path.UniformCost(g)

MODIFY
graph/path/dynamic/dstarlite_test.go
graph/path/dynamic/dstarlite_test.go
@@ -653,7 +653,7 @@ func samePath(a, b []graph.Node) bool {
}
// weightOf return the weight of the path in g.
-func weightOf(path []graph.Node, g graph.WeightedGraph) float64 {
+func weightOf(path []graph.Node, g graph.Weighted) float64 {
var w float64
if len(path) > 1 {
for p, n := range path[1:] {
@@ -668,7 +668,7 @@ func weightOf(path []graph.Node, g graph.WeightedGraph) float64 {
}
// simpleEdgesOf returns the weighted edges in g corresponding to the given edges.
-func simpleEdgesOf(g graph.WeightedGraph, edges []graph.Edge) []simple.Edge {
+func simpleEdgesOf(g graph.Weighted, edges []graph.Edge) []simple.Edge {
w := make([]simple.Edge, len(edges))
for i, e := range edges {
w[i].F = e.From()

MODIFY
graph/path/floydwarshall.go
graph/path/floydwarshall.go
@@ -13,7 +13,7 @@ import "gonum.org/v1/gonum/graph"
// The time complexity of FloydWarshall is O(|V|^3).
func FloydWarshall(g graph.Graph) (paths AllShortest, ok bool) {
var weight Weighting
- if wg, ok := g.(graph.WeightedGraph); ok {
+ if wg, ok := g.(graph.Weighted); ok {
weight = wg.Weight
} else {
weight = UniformCost(g)

MODIFY
graph/path/internal/limited_test.go
graph/path/internal/limited_test.go
@@ -1197,7 +1197,7 @@ func TestLimitedVisionGrid(t *testing.T) {
}
}
-func asConcreteEdges(changes []graph.Edge, in graph.WeightedGraph) []simple.Edge {
+func asConcreteEdges(changes []graph.Edge, in graph.Weighted) []simple.Edge {
if changes == nil {
return nil
}

MODIFY
graph/path/johnson_apsp.go
graph/path/johnson_apsp.go
@@ -22,7 +22,7 @@ func JohnsonAllPaths(g graph.Graph) (paths AllShortest, ok bool) {
from: g.From,
edgeTo: g.Edge,
}
- if wg, ok := g.(graph.WeightedGraph); ok {
+ if wg, ok := g.(graph.Weighted); ok {
jg.weight = wg.Weight
} else {
jg.weight = UniformCost(g)
@@ -82,7 +82,7 @@ var (
// to be explicit with the type since it
// is not exported.
_ graph.Graph = johnsonWeightAdjuster{}
- _ graph.WeightedGraph = johnsonWeightAdjuster{}
+ _ graph.Weighted = johnsonWeightAdjuster{}
)
func (g johnsonWeightAdjuster) Has(n graph.Node) bool {

graph,graph/{community,network,path}: rename WeightedGraph => Weighted