Beispiel #1
0
        /// <summary>
        /// Run the tutorial.
        /// </summary>
        public void Run()
        {
            // Create a new simple property graph
            var graph = GraphFactory.CreateGenericPropertyGraph(1);

            var v0 = graph.AddVertex("person", v => v.SetProperty("name", "Alice"));
            var v1 = graph.AddVertex("person", v => v.SetProperty("name", "Bob"));
            var v2 = graph.AddVertex("person", v => v.SetProperty("name", "Carol"));

            var e0 = graph.AddEdge(v0, v1);
            var e1 = graph.AddEdge(v1, v2);
            var e2 = graph.AddEdge(v2, v0);

            var TraversalGraph1 = new VertexVertex_MatrixListGraph(graph, "person", null);
            var TraversalGraph2 = new VertexEdge_MatrixListGraph  (graph);

            var v3 = graph.AddVertex("person", v => v.SetProperty("name", "Dave"));
            var v4 = graph.AddVertex("person", v => v.SetProperty("name", "Eve"));
            var v5 = graph.AddVertex("thing",  v => v.SetProperty("type", "car"));

            var e3 = graph.AddEdge(v0, v3);
            var e4 = graph.AddEdge(v1, v4);

            while (true)
            {
                Thread.Sleep(100);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Run the tutorial.
        /// </summary>
        public void Run()
        {
            var _Stopwatch               = new Stopwatch();
            var _Random                  = new Random();
            var _NumberOfVertices        = 10000;
            var _NumberOfEdges           = 600000;
            var _NumberOfConcurrentTasks = 10;

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

            _Stopwatch.Start();

            // Add vertices
            _NumberOfVertices.Loop(() => _graph.AddVertex());
            Console.WriteLine(_Stopwatch.Elapsed.TotalSeconds + "s : " + _NumberOfVertices + " vertices added.");

            // Add Edges
            _NumberOfEdges.Loop(() => _graph.AddEdge(_graph.VertexById((UInt64) _Random.Next(_NumberOfVertices)+1),
                                                     "knows",
                                                     _graph.VertexById((UInt64) _Random.Next(_NumberOfVertices)+1)));

            Console.WriteLine(_Stopwatch.Elapsed.TotalSeconds + "s : " + _NumberOfEdges + " vertices added.");

            //var Workload = _graph.Vertices().
            //               ToPartitions((UInt64) Math.Round((Double) _NumberOfVertices / (Double) _NumberOfConcurrentTasks));

            Double TimeStamp1, TimeStamp2;

            TimeStamp1 = _Stopwatch.Elapsed.TotalSeconds;
            var TraversalGraph = new VertexVertex_MatrixListGraph(_graph);
            TimeStamp2 = _Stopwatch.Elapsed.TotalSeconds;

            Console.WriteLine(Math.Round(TimeStamp2 - TimeStamp1, 6) + " secs to create the TraversalGraph.");

            #region Vertices.Out()

            //Console.WriteLine(Environment.NewLine + "Traversing all Vertices.Out()");

            TimeStamp1 = _Stopwatch.Elapsed.TotalSeconds;

            _graph.Vertices().Out().ForEach(x => { });

            TimeStamp2 = _Stopwatch.Elapsed.TotalSeconds;

            //Parallel.ForEach(_graph.Vertices(), x => x.Out().ForEach(y => { }));
            ////_graph.Vertices().AsParallel().Out().ForEach(x => { });

            //var TimeStamp3 = _Stopwatch.Elapsed.TotalSeconds;

            Console.WriteLine(Math.Round(TimeStamp2 - TimeStamp1, 6) + " secs (single threaded)");
            Console.WriteLine(Math.Round(_NumberOfEdges / (TimeStamp2 - TimeStamp1)) + " traversals per second (single threaded)");
            //Console.WriteLine(Math.Round(_NumberOfEdges / (TimeStamp3 - TimeStamp2)) + " traversals per second (multi threaded)");

            TimeStamp1 = _Stopwatch.Elapsed.TotalSeconds;

            _graph.Vertices().Out().ForEach(x => { });

            TimeStamp2 = _Stopwatch.Elapsed.TotalSeconds;

            Console.WriteLine(Math.Round(TimeStamp2 - TimeStamp1, 6) + " secs (single threaded)");
            Console.WriteLine(Math.Round(_NumberOfEdges / (TimeStamp2 - TimeStamp1)) + " traversals per second (single threaded)");

            #endregion

            #region Vertices.Out().Out()

            //Console.WriteLine(Environment.NewLine + "Traversing all Vertices.Out().Out()");

            //var TimeStamp4 = _Stopwatch.Elapsed.TotalSeconds;

            //_graph.Vertices().Out().Out().ForEach(x => { });

            //var TimeStamp5 = _Stopwatch.Elapsed.TotalSeconds;

            //Parallel.ForEach(_graph.Vertices(), x => x.Out().Out().ForEach(y => { }));

            ////_graph.Vertices().ForEach(x => x.OutDegree());

            ////var a = from v
            ////        in _graph.Vertices()//.AsParallel()
            ////        select v.OutDegree();

            //var TimeStamp6 = _Stopwatch.Elapsed.TotalSeconds;

            //Console.WriteLine(Math.Round((_NumberOfEdges^2) / (TimeStamp5 - TimeStamp4)) + " traversals per second (single threaded)");
            //Console.WriteLine(Math.Round((_NumberOfEdges^2) / (TimeStamp6 - TimeStamp5)) + " traversals per second (multi threaded)");

            #endregion

            while (true)
            {
                Thread.Sleep(100);
            }
        }