anchor.diff:                              for ks in choose (j+1) (i-1) do
                               yield n.[j] :: ks ]
               in choose 0 k  
  +
  +    let expectOneFailedWith f result = 
  +        result |> failed |> should be True
  +        match result with 
  +        | Bad [e] -> f e
  +        | _ -> false        
  +
  +    let isParsingFailure (gf: GraphFailure) = 
  +        match gf with 
  +        | ParsingFailure(_) -> true
  +        | _ -> false
                         
    
   open TestUtils
  
positive.code: let graphTypeTests = 
  
      testList "Graph ADT" [
          testCase "vertex lookup" <| fun _ ->
              let g = load_undirected_test_graph
              let v1 = Graph.vertexFromId g (VertexId 1)
              v1.Identifier |> should equal (VertexId 1)
  
          testCase "vert lookup with zero or less id throws " <| fun _ ->            
              let g = load_undirected_test_graph
              (fun () -> Graph.vertexFromId g (VertexId 0) |> ignore)
                  |> should throw typeof<System.Exception>
  
          testCase "vert lookup with out of range id throws" <| fun _ ->
              let g = load_undirected_test_graph
              (fun () -> Graph.vertexFromId g (VertexId 99) |> ignore)
                  |> should throw typeof<System.IndexOutOfRangeException>
                  
          testCase "vertices sequence is 1 based" <| fun _ ->
              let g = load_undirected_test_graph
              let verts = Graph.verticesSeq g
                          |> Array.ofSeq 
              verts |> Array.exists (fun vertex -> vertex.Identifier.Id = 0) 
                    |> should be False
      ]
  
  [<Tests>]
  let generationTests = 
  
      testList "Graph Generation" [
          testCase "Serialized header parsing" <| fun _ ->
              Generation.extractHeader "1 2" |> should equal (1, 2)
  
          testCase "Header parsing blows up on wrong number of inputs" <| fun _ ->
              (fun () -> Generation.extractHeader "1 2 3" |> ignore) 
                  |> should throw typeof<System.Exception>
  
          testCase "Header parsing blows up if cannot parse to numbers" <| fun _ ->
              (fun () -> Generation.extractHeader "a b" |> ignore) 
                  |> should throw typeof<System.FormatException>
  
          testCase "Vertex Id pair parsing" <| fun _ ->
              Generation.extractVertexIdPair "1 2" |> should equal (VertexId 1, VertexId 2)
  
          testCase "Vertex Id pair parsing blows if cannot parse numbers" <| fun _ ->
              (fun () -> Generation.extractVertexIdPair "a b" |> ignore) 
                  |> should throw typeof<System.FormatException>
  
          testCase "Vertex Id parsing blows up on wrong number of inputs" <| fun _ ->
              (fun () -> Generation.extractVertexIdPair "1 2 3" |> ignore) 
                  |> should throw typeof<System.Exception>
                          
          testCase "read undirected graph works" <| fun _ ->
              let isDirected = false
              let g = Generation.readGraph (test_graph_file "undirected_graph.txt") isDirected
              g.VerticesCount |> should equal 4
              g.EdgesCount |> should equal 5
              g.IsDirected |> should be False
              let adjacents = 
                  neighbourIdNumbers g 
              adjacents 1 |> should equal [2; 4]
              adjacents 2 |> should equal [1; 3; 4]
              adjacents 3 |> should equal [2; 4]
              adjacents 4 |> should equal [1; 2; 3]
  
          testCase "read directed graph works" <| fun _ ->
              let isDirected = true
              let g = Generation.readGraph (test_graph_file "directed_graph.txt") isDirected
              g.VerticesCount |> should equal 5
              g.EdgesCount |> should equal 8
              g.IsDirected |> should be True
              let adjacents = 
                  neighbourIdNumbers g 
              adjacents 1 |> should equal [2]
              adjacents 2 |> should equal [5]
              adjacents 3 |> should equal [1; 4]
              adjacents 4 |> should equal [3]
              adjacents 5 |> should equal [1; 3; 4]
  
          // Malicious / incorrect vertex numbers not currently cleanly handled:
          // - vertexIds out of range
          // - zero based indexing (we use 1-based)
      ]   
  
  [<Tests>]
  
negative.code: 
      let load_undirected_test_graph = 
          let isDirected = false
          Generation.readGraphFromFile isDirected (test_graph_file "undirected_graph.txt") 
  
      let load_directed_test_graph = 
          let isDirected = true
          Generation.readGraphFromFile isDirected (test_graph_file "directed_graph.txt")
  
      let neighbours graph vertexIdNumber = 
          VertexId vertexIdNumber 
          |> Graph.vertexFromId graph 
          |> lift (fun v -> v.Neighbours)
  
      let neighbourIdNumbers graph vertexIdNumber = 
          trial {
              let! neighbourIds = neighbours graph vertexIdNumber
              let ns = neighbourIds 
                       |> Seq.map (fun vId -> vId.Id)
                       |> Array.ofSeq
                       |> Array.sort
              return ns            
          }
          
      let inline factorial (n: int): bigint = 
          if n < 0 then 
              failwith "negative faculty"  
  