Ejemplo n.º 1
0
        public static void UsingAGraphTypeHelper()
        {
            //Create a clique helper
            Clique <Guid> cliqueHelper = new Clique <Guid>(VertexFactory: new StatefulVertexFactory <VertexState>(new EnumState(VertexState.HEALTHY)),
                                                           EdgeFactory: new DefaultEdgeFactory(),
                                                           IdentityProvider: new DefaultIdentityProvider());
            //Use it to construct a graph
            Graph <Guid> cliqueGraph = cliqueHelper.Create(100).Graph;

            //StatefulVertexFactory gives all vertices a default value of VertexState.HEALTHY.
            //For the simulation we need at least one mutant. The first vertex will do.
            StatefulVertex <Guid, VertexState> v = cliqueGraph.Vertices.OfType <StatefulVertex <Guid, VertexState> >().First();

            v.State.ChangeStateValue(VertexState.MUTANT);

            MoranProcessRunner moranProcess = new MoranProcessRunner(new StateSelector(), new VertexSelector(), new VictimSelector());
            MoranProcessResult result       = moranProcess.RunOn(cliqueGraph, 1000, 10000, 3.0d);

            Console.WriteLine("UsingAGraphTypeHelper :: Result");
            Console.WriteLine("\t Repetitions " + result.RepetitionsPerformed);
            Console.WriteLine("\t Fixations " + result.Fixations);
            Console.WriteLine("\t Extinctions " + result.Extinctions);
            Console.WriteLine("\t Timeouts" + result.Timeout);
            Console.WriteLine("\t p(Fixation) " + result.FixationProbability);
            Console.WriteLine("\t p(Extinction) " + result.ExtinctionProbability);
            Console.WriteLine("\t p(Timeout) " + result.TimeoutProbability);
        }
Ejemplo n.º 2
0
        public static void BasicClique()
        {
            //The non-generic clique is an implementation of Clique<Guid>
            //which uses DefaultVertexFactory, DefaultEdgeFactory and DefaultIdentityProvider
            Clique cliqueHelper = new Clique();

            //The identity type must be specified because type inference can't help here
            CliqueInfo <Guid> clique = cliqueHelper.Create(100);

            //The graph representing the clique is the Graph property
            Graph <Guid> cliqueGraph = clique.Graph;
        }
Ejemplo n.º 3
0
        public static void AdvancedClique()
        {
            //The generic clique takes a vertex factory, edge factory and identity provider.
            //Pass the default implementation of any parameters you want default behaviour for
            //The factory and identity provider implementations must match the identity type of the chain (eg Guid)
            Clique <Guid> cliqueHelper = new Clique <Guid>(new StatefulVertexFactory <VertexState>(new EnumState(VertexState.HEALTHY)),
                                                           new DefaultEdgeFactory(),
                                                           new DefaultIdentityProvider());

            //The identity type must be specified because type inference can't help here
            CliqueInfo <Guid> clique = cliqueHelper.Create(100);

            //The graph representing the clique is the Graph property
            Graph <Guid> cliqueGraph = clique.Graph;
        }