示例#1
0
        /// <summary>
        /// Run the tutorial.
        /// </summary>
        public void Run()
        {
            var Stopwatch = new Stopwatch();
            var PRNG      = new Random();

            // Create a new simple property graph
            var _Graph    = GraphFactory.CreateGenericPropertyGraph(1);

            var NumberOfUsers           = 20000UL;
            var NumberOfIterations      = 30;
            var MinNumberOfEdges        = 15;
            var MaxNumberOfEdges        = 25;

            var CountedNumberOfEdges    = 0UL;

            var d = new Dictionary<UInt64, UInt64>();
            for (var i = 0UL; i < NumberOfUsers; i++)
            {
                d.Add(i, i);
            }

            Stopwatch.Restart();
            foreach (var INT in d)
                CountedNumberOfEdges += INT.Value;
            Stopwatch.Stop();
            Console.WriteLine(Stopwatch.Elapsed.TotalMilliseconds + "ms");

            Stopwatch.Restart();
            var b = new UInt64[NumberOfUsers];
            foreach (var INT in b)
                CountedNumberOfEdges += INT;
            Stopwatch.Stop();
            Console.WriteLine(Stopwatch.Elapsed.TotalMilliseconds + "ms");

            IReadOnlyGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                           UInt64, Int64, String, String, Object,
                                           UInt64, Int64, String, String, Object,
                                           UInt64, Int64, String, String, Object> ActualVertex = null;

            var Vertices = new IReadOnlyGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                              UInt64, Int64, String, String, Object,
                                                              UInt64, Int64, String, String, Object,
                                                              UInt64, Int64, String, String, Object>[NumberOfUsers + 1];

            var Measurements = new Double[NumberOfIterations];

            Stopwatch.Start();

            Vertices[0] = _Graph.AddVertex(1-1, "default");

            for (var VertexId = 2UL - 1; VertexId < NumberOfUsers; VertexId++)
            {

                ActualVertex = _Graph.AddVertex(VertexId, "default", v => v.SetProperty("Name", "User" + VertexId)
                                                                           .SetProperty("Age",  PRNG.Next(0, 150)));
                Vertices[VertexId-1] = ActualVertex;
                _Graph.AddEdge(ActualVertex, Vertices[PRNG.Next(0, (Int32) VertexId-1)]);

                var NumberOfAdditionalEdges = (UInt64) PRNG.Next(MinNumberOfEdges, MaxNumberOfEdges);

                do
                {
                    _Graph.AddEdge(ActualVertex, Vertices[PRNG.Next(0, (Int32) VertexId - 1)]);
                } while (ActualVertex.OutDegree() < NumberOfAdditionalEdges);

                if (VertexId % 10000UL == 0)
                    Console.WriteLine(VertexId);

            }

            Stopwatch.Stop();
            Console.WriteLine("Creation Time: " + Stopwatch.Elapsed.TotalMilliseconds + "ms");
            Console.WriteLine();

            //var _ROGraph = new SimpleReadOnlyPropertyGraph(2, _Graph,
            //                                               SyncedVertexIds:  true,
            //                                               SyncedEdgeIds:    true
            //                                               );

            for (var Iteration = 0; Iteration < NumberOfIterations; Iteration++)
            {

                CountedNumberOfEdges = 0;

                Stopwatch.Restart();

                foreach (var _Vertex in _Graph.Vertices())
                {
                    CountedNumberOfEdges += (UInt64) _Vertex.OutDegree();
                }

                Stopwatch.Stop();
                Measurements[Iteration] = Stopwatch.Elapsed.TotalMilliseconds;
                Console.WriteLine(CountedNumberOfEdges + " edges in " + Stopwatch.Elapsed.TotalMilliseconds + "ms");

            }

            //var AverageAndStdDev = Measurements.AverageAndStdDev();
            //Console.WriteLine("Mean: " + AverageAndStdDev.Item1 + ", stddev: " + AverageAndStdDev.Item2);
            //Console.ReadLine();
        }
示例#2
0
        public virtual Boolean AddVertex(IReadOnlyGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                                        UInt64, Int64, String, String, Object,
                                                                        UInt64, Int64, String, String, Object,
                                                                        UInt64, Int64, String, String, Object> Vertex)
        {

            if (VertexFilter == null || VertexFilter(Vertex))
            {
                _MatrixListGraph.Add(new List<UInt64>(Func(Vertex)));
                return true;
            }

            return false;

        }
示例#3
0
        /// <summary>
        /// Run the tutorial.
        /// </summary>
        public void Run()
        {
            var Stopwatch = new Stopwatch();
            var PRNG      = new Random();

            // Create a new simple property graph
            var _Graph = GraphFactory.CreateGenericPropertyGraph(1);

            var NumberOfUsers      = 20000UL;
            var NumberOfIterations = 30;
            var MinNumberOfEdges   = 15;
            var MaxNumberOfEdges   = 25;

            var CountedNumberOfEdges = 0UL;


            var d = new Dictionary <UInt64, UInt64>();

            for (var i = 0UL; i < NumberOfUsers; i++)
            {
                d.Add(i, i);
            }

            Stopwatch.Restart();
            foreach (var INT in d)
            {
                CountedNumberOfEdges += INT.Value;
            }
            Stopwatch.Stop();
            Console.WriteLine(Stopwatch.Elapsed.TotalMilliseconds + "ms");

            Stopwatch.Restart();
            var b = new UInt64[NumberOfUsers];

            foreach (var INT in b)
            {
                CountedNumberOfEdges += INT;
            }
            Stopwatch.Stop();
            Console.WriteLine(Stopwatch.Elapsed.TotalMilliseconds + "ms");


            IReadOnlyGenericPropertyVertex <UInt64, Int64, String, String, Object,
                                            UInt64, Int64, String, String, Object,
                                            UInt64, Int64, String, String, Object,
                                            UInt64, Int64, String, String, Object> ActualVertex = null;

            var Vertices = new IReadOnlyGenericPropertyVertex <UInt64, Int64, String, String, Object,
                                                               UInt64, Int64, String, String, Object,
                                                               UInt64, Int64, String, String, Object,
                                                               UInt64, Int64, String, String, Object> [NumberOfUsers + 1];

            var Measurements = new Double[NumberOfIterations];

            Stopwatch.Start();

            Vertices[0] = _Graph.AddVertex(1 - 1, "default");

            for (var VertexId = 2UL - 1; VertexId < NumberOfUsers; VertexId++)
            {
                ActualVertex = _Graph.AddVertex(VertexId, "default", v => v.SetProperty("Name", "User" + VertexId)
                                                .SetProperty("Age", PRNG.Next(0, 150)));
                Vertices[VertexId - 1] = ActualVertex;
                _Graph.AddEdge(ActualVertex, Vertices[PRNG.Next(0, (Int32)VertexId - 1)]);

                var NumberOfAdditionalEdges = (UInt64)PRNG.Next(MinNumberOfEdges, MaxNumberOfEdges);

                do
                {
                    _Graph.AddEdge(ActualVertex, Vertices[PRNG.Next(0, (Int32)VertexId - 1)]);
                } while (ActualVertex.OutDegree() < NumberOfAdditionalEdges);

                if (VertexId % 10000UL == 0)
                {
                    Console.WriteLine(VertexId);
                }
            }

            Stopwatch.Stop();
            Console.WriteLine("Creation Time: " + Stopwatch.Elapsed.TotalMilliseconds + "ms");
            Console.WriteLine();

            //var _ROGraph = new SimpleReadOnlyPropertyGraph(2, _Graph,
            //                                               SyncedVertexIds:  true,
            //                                               SyncedEdgeIds:    true
            //                                               );

            for (var Iteration = 0; Iteration < NumberOfIterations; Iteration++)
            {
                CountedNumberOfEdges = 0;

                Stopwatch.Restart();

                foreach (var _Vertex in _Graph.Vertices())
                {
                    CountedNumberOfEdges += (UInt64)_Vertex.OutDegree();
                }

                Stopwatch.Stop();
                Measurements[Iteration] = Stopwatch.Elapsed.TotalMilliseconds;
                Console.WriteLine(CountedNumberOfEdges + " edges in " + Stopwatch.Elapsed.TotalMilliseconds + "ms");
            }

            //var AverageAndStdDev = Measurements.AverageAndStdDev();
            //Console.WriteLine("Mean: " + AverageAndStdDev.Item1 + ", stddev: " + AverageAndStdDev.Item2);
            //Console.ReadLine();
        }