FSharp.FGL icon indicating copy to clipboard operation
FSharp.FGL copied to clipboard

[Bug] Undirected edges.map can lead to unequal edgeweights

Open HLWeil opened this issue 4 years ago • 0 comments

Repro steps

open FSharp.FGL.Undirected

let rnd = System.Random()

let myGraph = 
   FSharp.FGL.Directed.Models.gilbert (fun i -> i,i) 4 0.3
   |> FSharp.FGL.Directed.Edges.undirect (fun _ _ -> 1)

myGraph 
|> Edges.map (fun _ _ _ -> rnd.NextDouble())`

Expected behavior

Edge from 0 -> 1 and 1 -> 0 should have the same weights

Actual behavior

Edge from 0 -> 1 and 1 -> 0 have the different weights

Solution

The function should only be applied once and the value should be used for both "directions"

HLWeil avatar Sep 16 '20 09:09 HLWeil