Esempio n. 1
0
        public static UndirectedGraph <int, Edge <int> > CreateGraphArrayOfNodesAndEdgesAssume([PexAssumeNotNull] int[] nodes,
                                                                                               [PexAssumeNotNull] bool[] edges)
        {
            //PexAssume.IsTrue(nodes.Length <= 7 || nodes.Length > 7);
            PexAssume.IsTrue(edges.Length <= 6 || nodes.Length > 6);
            PexAssume.IsTrue(edges.Length <= nodes.Length);
            PexAssume.AreDistinctValues(nodes);
            //PexAssume.TrueForAll(nodes, e => e != 0);

            UndirectedGraph <int, Edge <int> > g = new UndirectedGraph <int, Edge <int> >(false);

            foreach (int ele in nodes)
            {
                g.AddVertex(ele);
            }

            int source = PexChoose.IndexValue("indexed value", nodes);

            for (int i = 0; i < edges.Length; i++)
            {
                if (edges[i] == false)
                {
                    g.AddEdge(new Edge <int>(nodes[source], nodes[i]));
                }
            }
            return(g);
        }
        public static UndirectedGraph <int, Edge <int> > CreateGraphArrayOfNodesAndEdges([PexAssumeNotNull] int[] nodes,
                                                                                         [PexAssumeNotNull] bool[] edges)
        {
            PexAssume.IsTrue(edges.Length == nodes.Length);
            PexAssume.AreDistinctValues(nodes);
            PexAssume.TrueForAll(nodes, e => e <= 10 || e > 10);
            PexAssume.TrueForAll(nodes, e => e != 0);
            UndirectedGraph <int, Edge <int> > g = new UndirectedGraph <int, Edge <int> >(false);

            foreach (int ele in nodes)
            {
                g.AddVertex(ele);
            }
            for (int i = 0; i < edges.Length; i++)
            {
                int source = PexChoose.IndexValue("indexed value", nodes);
                PexObserve.ValueForViewing("CANED_SRC", source);
                if (edges[source] == false)
                {
                    g.AddEdge(new Edge <int>(nodes[source], nodes[i]));
                    g.AddEdge(new Edge <int>(nodes[i], nodes[i]));
                }
            }
            return(g);
        }