CSBiology / FSharp.FGL

Functional graph library for F#
https://csbiology.github.io/FSharp.FGL/
MIT License
61 stars 11 forks source link

[Docs] `List.init` mistake in AdjacencyGraph tutorial #51

Closed omaus closed 1 year ago

omaus commented 1 year ago

Found a problem with existing documentation?

//Creating a list of labeled vertices
let vertexList : LVertex<int,string> list = 
    List.init 4 (fun i -> 
    i,
    sprintf "VertexNr. %i" i)

Since basic collections in F# are 0-based, the resulting verteces will have index 0 to 3, but the adjacency graph needs 1-based verteces. Otherwise they are omitted on creation. Correct:

//Creating a list of labeled vertices
let vertexList : LVertex<int,string> list = 
    List.init 4 (fun i -> 
    i + 1,
    sprintf "VertexNr. %i" (i + 1))

Edit: Error not reproducible.