Exemplo n.º 1
0
        /// <summary>
        /// Creates a scale free network
        /// </summary>
        /// <param name="nodeCound"></param>
        /// <param name="edgeCount"></param>
        /// <param name="fallen8"></param>
        public void CreateScaleFreeNetwork(int nodeCound, int edgeCount)
        {
            var creationDate = DateHelper.ConvertDateTime(DateTime.Now);
            var vertexIDs    = new List <Int32> ();
            var prng         = new Random();

            if (nodeCound < _numberOfToBeTestedVertices)
            {
                _numberOfToBeTestedVertices = nodeCound;
            }

            _toBeBenchenVertices = new List <VertexModel> (_numberOfToBeTestedVertices);

            for (var i = 0; i < nodeCound; i++)
            {
//                vertexIDs.Add(
//                    fallen8.CreateVertex(creationDate, new PropertyContainer[4]
//                                                           {
//                                                               new PropertyContainer { PropertyId = 23, Value = 4344 },
//                                                               new PropertyContainer { PropertyId = 24, Value = "Ein gaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaanz langes Property" },
//                                                               new PropertyContainer { PropertyId = 25, Value = "Ein kurzes Property" },
//                                                               new PropertyContainer { PropertyId = 26, Value = "Ein gaaaaaaaanz langes Property" },
//                                                           }).Id);
                vertexIDs.Add(_f8.CreateVertex(creationDate).Id);
            }

            if (edgeCount != 0)
            {
                foreach (var aVertexId in vertexIDs)
                {
                    var targetVertices = new HashSet <Int32> ();

                    do
                    {
                        targetVertices.Add(vertexIDs [prng.Next(0, vertexIDs.Count)]);
                    } while (targetVertices.Count < edgeCount);

                    foreach (var aTargetVertex in targetVertices)
                    {
//                    fallen8.CreateEdge(aVertexId, 0, aTargetVertex, creationDate, new PropertyContainer[2]
//                                                           {
//                                                               new PropertyContainer { PropertyId = 29, Value = 23.4 },
//                                                               new PropertyContainer { PropertyId = 1, Value = 2 },
//                                                           });
//
                        _f8.CreateEdge(aVertexId, 0, aTargetVertex, creationDate);
                    }
                }

                _toBeBenchenVertices.AddRange(PickInterestingIDs(vertexIDs, prng)
                                              .Select(aId => {
                    VertexModel v = null;

                    _f8.TryGetVertex(out v, aId);

                    return(v);
                }));
            }
        }
Exemplo n.º 2
0
        public int AddVertex(VertexSpecification definition)
        {
            #region initial checks

            if (definition == null)
            {
                throw new ArgumentNullException("definition");
            }

            #endregion

            return(_fallen8.CreateVertex(definition.CreationDate, ServiceHelper.GenerateProperties(definition.Properties)).Id);
        }
Exemplo n.º 3
0
        public void CreateGraph(int nodeCount, int edgeCount)
        {
            _f8.TabulaRasa();
            var creationDate = DateHelper.ConvertDateTime(DateTime.Now);
            var vertexIDs    = new List <Int32> ();
            var prng         = new Random();

            if (nodeCount < _numberOfToBeTestedVertices)
            {
                _numberOfToBeTestedVertices = nodeCount;
            }

            _toBeBenchenVertices = new List <VertexModel> (_numberOfToBeTestedVertices);

            for (var i = 0; i < nodeCount; i++)
            {
                vertexIDs.Add(_f8.CreateVertex(creationDate).Id);
            }

            if (edgeCount != 0)
            {
                foreach (var aVertexId in vertexIDs)
                {
                    var targetVertices = new HashSet <Int32> ();

                    do
                    {
                        targetVertices.Add(vertexIDs [prng.Next(0, vertexIDs.Count)]);
                    } while (targetVertices.Count < edgeCount);

                    foreach (var aTargetVertex in targetVertices)
                    {
                        _f8.CreateEdge(aVertexId, 0, aTargetVertex, creationDate);
                    }
                }

                _toBeBenchenVertices.AddRange(PickInterestingIDs(vertexIDs, prng)
                                              .Select(aId => {
                    VertexModel v = null;

                    _f8.TryGetVertex(out v, aId);

                    return(v);
                }));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a random graph
        /// </summary>
        /// <param name="vertexCount">The vertex count</param>
        /// <param name="edgesPerVertex">The max number of edges per vertex</param>
        /// <returns>The F8 graph</returns>
        public static Fallen8 CreateRandomGraph(int vertexCount, int edgesPerVertex)
        {
            var result = new Fallen8();

            var propertyCount = 5;
            var vertexIDs     = new List <int>();
            var prng          = new Random();

            var availableProperties = GenerateProperties();

            for (int i = 0; i < vertexCount; i++)
            {
                var creationDate = Convert.ToUInt32(prng.Next(0, Int32.MaxValue));
                var properties   = AssembleSomeProperties(availableProperties, prng, propertyCount);

                vertexIDs.Add(result.CreateVertex(creationDate, properties).Id);
            }

            for (int i = 0; i < vertexIDs.Count; i++)
            {
                var sourceId     = vertexIDs[i];
                var countOfEdges = prng.Next(0, edgesPerVertex);

                for (int j = 0; j < countOfEdges; j++)
                {
                    var edgePropertyId = Convert.ToUInt16(prng.Next(UInt16.MinValue, UInt16.MaxValue));
                    var creationDate   = Convert.ToUInt32(prng.Next(0, Int32.MaxValue));
                    var properties     = AssembleSomeProperties(availableProperties, prng, propertyCount);
                    var targetId       = vertexIDs[prng.Next(0, vertexIDs.Count)];

                    result.CreateEdge(sourceId, edgePropertyId, targetId, creationDate, properties);
                }
            }

            return(result);
        }