public void testBigGraphWithNoEdges() { var _Graph = TinkerGraphFactory.CreateTinkerGraph(); for (var i = 0; i < 100000; i++) _Graph.AddVertex(); var _Vertices = new AllVerticesPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); _Vertices.SetSource(new SingleEnumerator<IGenericPropertyGraph<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_Graph)); var _OutEdges = new OutEdgesPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); _OutEdges.SetSource(_Vertices); var _Counter = 0; while (_OutEdges.MoveNext()) _Counter++; Assert.AreEqual(0, _Counter); }
public void TestPathPipe() { var _graph = DemoGraphFactory.CreateSimpleGraph(); var Alice = _graph.VertexById("Alice").AsMutable(); var _Pipe1 = new OutEdgesPipe<String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object>(); var _Pipe2 = new InVertexPipe<String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object>(); var _Pipe3 = new PathPipe<IReadOnlyGenericPropertyVertex<String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object>>(); var _Pipeline = new Pipeline<IReadOnlyGenericPropertyVertex<String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object>, IEnumerable<Object>>(_Pipe1, _Pipe2, _Pipe3); _Pipeline.SetSource(new SingleEnumerator<IReadOnlyGenericPropertyVertex<String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object>>(Alice)); // Via pipeline... var query1 = _Pipeline.Select(path => path.Select(q => ((IIdentifier<String>) q).Id)).ToArray(); Assert.AreEqual(3, query1.Length); Assert.AreEqual(3, query1[0].Count(), "'" + query1[0].AggString() + "' is invalid!"); Assert.AreEqual(3, query1[1].Count(), "'" + query1[1].AggString() + "' is invalid!"); Assert.AreEqual(3, query1[2].Count(), "'" + query1[2].AggString() + "' is invalid!"); Assert.AreEqual("Alice|Alice -loves-> Bob|Bob", query1[0].AggString()); Assert.AreEqual("Alice|0|Bob", query1[1].AggString()); Assert.AreEqual("Alice|2|Carol", query1[2].AggString()); // Via extention methods... var query2 = Alice.OutE().InV().Paths().ToArray(); Assert.AreEqual(3, query2.Length); Assert.AreEqual(3, query2[0].Count(), "'" + query2[0].Select(q => ((IIdentifier<String>) q).Id).AggString() + "' is invalid!"); Assert.AreEqual(3, query2[1].Count(), "'" + query2[1].Select(q => ((IIdentifier<String>) q).Id).AggString() + "' is invalid!"); Assert.AreEqual(3, query2[2].Count(), "'" + query2[2].Select(q => ((IIdentifier<String>) q).Id).AggString() + "' is invalid!"); var query3 = Alice.Out().Paths().ToArray(); Assert.AreEqual(3, query2.Length); Assert.AreEqual(3, query2[0].Count(), "'" + query2[0].Select(q => ((IIdentifier<String>) q).Id).AggString() + "' is invalid!"); Assert.AreEqual(3, query2[1].Count(), "'" + query2[1].Select(q => ((IIdentifier<String>) q).Id).AggString() + "' is invalid!"); Assert.AreEqual(3, query2[2].Count(), "'" + query2[2].Select(q => ((IIdentifier<String>) q).Id).AggString() + "' is invalid!"); }
public void testGraphFutureFilter() { var _Graph = TinkerGraphFactory.CreateTinkerGraph(); var _Marko = _Graph.VertexById(1); var _OutEPipe = new OutEdgesPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _InVPipe = new InVertexPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _PropertyFilterPipe = new VertexPropertyFilterPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>("name", v => v.Equals("lop")); var _FutureFilterPipe = new FutureFilterPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>( new Pipeline<IGenericPropertyEdge<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>, IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_InVPipe, _PropertyFilterPipe)); var _Pipeline = new Pipeline<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>, IGenericPropertyEdge<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_OutEPipe, _FutureFilterPipe); _Pipeline.SetSourceCollection(new List<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>() { _Marko }); int _Counter = 0; while (_Pipeline.MoveNext()) { _Counter++; Assert.AreEqual(9, _Pipeline.Current.Id); } Assert.AreEqual(1, _Counter); }
public void testUniquePathFilter() { var _Graph = TinkerGraphFactory.CreateTinkerGraph(); var _Pipe1 = new OutEdgesPipe <UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe2 = new InVertexPipe <UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe3 = new InEdgesPipe <UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe4 = new OutVertexPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe5 = new UniquePathFilterPipe<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(); var _Pipeline = new Pipeline<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>, IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_Pipe1, _Pipe2, _Pipe3, _Pipe4, _Pipe5); _Pipeline.SetSource(new SingleEnumerator<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_Graph.VertexById(1))); var _Counter = 0; foreach (var _Object in _Pipeline) { _Counter++; Assert.IsTrue(_Object.Equals(_Graph.VertexById(6)) || _Object.Equals(_Graph.VertexById(4))); } Assert.AreEqual(2, _Counter); }
public void testPropertyFilter() { var _Graph = TinkerGraphFactory.CreateTinkerGraph(); var _Marko = _Graph.VertexById(1); var _Pipe1 = new OutEdgesPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe2 = new InVertexPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe3 = new VertexPropertyFilterPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>("lang", v => v == "java"); var _Pipeline = new Pipeline<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>, IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(new List<IPipe>() { _Pipe1, _Pipe2, _Pipe3 }); _Pipeline.SetSource(new List<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>() { _Marko }.GetEnumerator()); var _Counter = 0; while (_Pipeline.MoveNext()) { _Counter++; var _Vertex = _Pipeline.Current; Assert.AreEqual(3, _Vertex.Id); Assert.AreEqual("java", _Vertex.GetProperty("lang")); Assert.AreEqual("lop", _Vertex.GetProperty("name")); } Assert.AreEqual(1, _Counter); }
public void testFilterIds1() { var _Graph = TinkerGraphFactory.CreateTinkerGraph(); var _Marko = _Graph.VertexById(1); var _Pipe1 = new OutEdgesPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe2 = new InVertexPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe3 = new VertexIdFilterPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(v => v != 3); var _Pipeline = new Pipeline<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>, IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_Pipe1, _Pipe2, _Pipe3); _Pipeline.SetSourceCollection(new List<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>() { _Marko }); var _Counter = 0; while (_Pipeline.MoveNext()) { var _Vertex = _Pipeline.Current; Assert.AreEqual("lop", _Vertex.GetProperty("name")); _Counter++; } Assert.AreEqual(1, _Counter); }
public void testPipeBasic() { var _Graph = TinkerGraphFactory.CreateTinkerGraph(); var _Marko = _Graph.VertexById(1); var _Pipe1 = new OutEdgesPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe2 = new InVertexPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe3 = new PathPipe<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(); var _Pipeline = new Pipeline<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>, IEnumerable<Object>>(_Pipe1, _Pipe2, _Pipe3); _Pipeline.SetSource(new SingleEnumerator<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_Marko)); foreach (var _Path in _Pipeline) { Assert.AreEqual(_Marko, _Path.ElementAt(0)); Assert.IsTrue(_Path.ElementAt(1) is IPropertyEdge); Assert.IsTrue(_Path.ElementAt(2) is IPropertyVertex); } }
public void testBasicGather() { var _Graph = TinkerGraphFactory.CreateTinkerGraph(); var _Pipe0 = new OutEdgesPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe1 = new InVertexPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe2 = new GatherPipe<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(); var _Pipeline = new Pipeline<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>, IEnumerable<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>>(_Pipe0, _Pipe1, _Pipe2); _Pipeline.SetSource(new SingleEnumerator<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_Graph.VertexById(1))); while (_Pipeline.MoveNext()) Console.WriteLine(_Pipeline.Current + "--->");// + pipeline.Path); }
public void testOutGoingEdges() { var _Graph = TinkerGraphFactory.CreateTinkerGraph(); var _Marko = _Graph.VertexById(1); var _VSF = new OutEdgesPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); _VSF.SetSource(new List<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>() { _Marko }.GetEnumerator()); var _Counter = 0; while (_VSF.MoveNext()) { var _E = _VSF.Current; Assert.AreEqual(_Marko, _E.OutVertex); Assert.IsTrue(_E.InVertex.Id.Equals(2) || _E.InVertex.Id.Equals(3) || _E.InVertex.Id.Equals(4)); _Counter++; } Assert.AreEqual(3, _Counter); var _Josh = _Graph.VertexById(4); _VSF = new OutEdgesPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); _VSF.SetSource(new List<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>() { _Josh }.GetEnumerator()); _Counter = 0; while (_VSF.MoveNext()) { var e = _VSF.Current; Assert.AreEqual(_Josh, e.OutVertex); Assert.IsTrue(e.InVertex.Id.Equals(5) || e.InVertex.Id.Equals(3)); _Counter++; } Assert.AreEqual(2, _Counter); var _Lop = _Graph.VertexById(3); _VSF = new OutEdgesPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); _VSF.SetSource(new List<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>() { _Lop }.GetEnumerator()); _Counter = 0; while (_VSF.MoveNext()) { _Counter++; } Assert.AreEqual(0, _Counter); }
//private static Runner _Compiler; #endregion //#region (static) StartMonoCSharpREPLShell(Args) ///// <summary> ///// The Mono C# REPL Shell ///// </summary> //public static void StartMonoCSharpREPLShell(params String[] Args) //{ // #region Feel free to step through... // _Compiler = new Runner(); // var a = _Compiler.Execute("Math.Abs(-42);"); // var b = _Compiler.Execute("Math.Sin(Math.PI / 6);"); // var c = _Compiler.Execute("class Fact { public int Run(int n) { return n <= 0 ? 1 : n*Run(n-1); } }"); // var d = _Compiler.Execute("new Fact().Run(5);"); // var e = _Compiler.Execute("\"abcdefgh\".Substring(1, 2);"); // var f = _Compiler.Execute("class Echo { public Object Print(Object o) { return o; } }"); // var g = _Compiler.Execute("var test = 123;"); // var h = _Compiler.Execute("new Echo().Print(test);"); // #endregion // #region Start the interactive (read-eval-print loop) shell... // var _Report = new Report(new ConsoleReportPrinter()); // var _CLP = new CommandLineParser(_Report); // _CLP.UnknownOptionHandler += Mono.Driver.HandleExtraArguments; // var _Settings = _CLP.ParseArguments(Args); // if (_Settings == null || _Report.Errors > 0) // Environment.Exit(1); // var _Evaluator = new Evaluator(_Settings, _Report) // { // InteractiveBaseClass = typeof(InteractiveBaseShell), // DescribeTypeExpressions = true // }; // //// Adding a assembly twice will lead to delayed errors... // //_Evaluator.ReferenceAssembly(typeof(YourAssembly).Assembly); // _Evaluator.ReferenceAssembly(typeof(Bragi).Assembly); // _Evaluator.ReferenceAssembly(typeof(IPropertyGraph).Assembly); // _Evaluator.ReferenceAssembly(typeof(GraphFactory).Assembly); // var u1 = _Compiler.Execute("using de.ahzf.Bragi;"); // var u2 = _Compiler.Execute("using de.ahzf.Blueprints;"); // var u3 = _Compiler.Execute("using de.ahzf.Balder.PropertyGraphs;"); // var u4 = _Compiler.Execute("using de.ahzf.Balder.PropertyGraphs.InMemory"); // var _CSharpShell = new CSharpShell(_Evaluator, "BragiShell").Run(); // #endregion //} //#endregion /// <summary> /// Main... /// </summary> /// <param name="Args">Arguments...</param> public static void Main(String[] Args) { var _graph = DemoGraphFactory.CreateSimpleGraph(); var Alice = _graph.VertexById("Alice").AsMutable(); var _Pipe1 = new OutEdgesPipe <String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object>(); var _Pipe2 = new InVertexPipe <String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object>(); var _Pipe3 = new PathPipe <IReadOnlyGenericPropertyVertex <String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object> >(); var _Pipeline = new Pipeline <IReadOnlyGenericPropertyVertex <String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object>, IEnumerable <Object> >(_Pipe1, _Pipe2, _Pipe3); _Pipeline.SetSource(new SingleEnumerator <IReadOnlyGenericPropertyVertex <String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object> >(Alice)); var x1 = _Pipeline.Select(path => path.Select(q => ((IIdentifier <String>)q).Id).Aggregate((a, b) => a + "|" + b)); var x2 = Alice.OutE().InV().Paths().ToArray(); foreach (var _Path in x1) { //var a0 = _Path.ElementAt(0); //var b0 = _Path.ElementAt(1) is IReadOnlyGenericPropertyEdge <String, Int64, String, String, Object, // String, Int64, String, String, Object, // String, Int64, String, String, Object, // String, Int64, String, String, Object>; //var c0 = _Path.ElementAt(2) is IReadOnlyGenericPropertyVertex<String, Int64, String, String, Object, // String, Int64, String, String, Object, // String, Int64, String, String, Object, // String, Int64, String, String, Object>; } Sigma_js.Start(); //Transactions.Start(); //NotificationsDemo.Start(); //Vanaheimr.Start(); //MulticastDemo.Start(); //PartitionGraphs.Start(); //TraversalGraphs.Start(); //NetworkingDemo.Start(); //TagExample.Start(); //PolyfileReader.Start(); //StartMonoCSharpREPLShell(); // Try to type: // "using de.ahzf.Bragi;" // // and then one of the following... // // "TagExample.Start();" // "ConcurrencyDemo.Start();" // "NetworkingDemo.Start();" // "SmallBenchmark.Start();" }
public void testAndOrPipeGraph() { // ./outE[@label='created' or (@label='knows' and @weight > 0.5)] var _Graph = TinkerGraphFactory.CreateTinkerGraph(); var _Marko = _Graph.VertexById(1); var _Pipe1 = new OutEdgesPipe <UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _PipeA = new EdgeLabelFilterPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(v => v != "created"); var _PipeB = new EdgeLabelFilterPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(v => v != "knows"); var _PipeC = new EdgePropertyFilterPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>("weight", v => (0.5).Equals(v)); var _PipeD = new AndFilterPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>( new HasNextPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_PipeB), new HasNextPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_PipeC)); var _Pipe2 = new OrFilterPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>( new HasNextPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_PipeA), new HasNextPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_PipeD)); var _Pipeline = new Pipeline<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>, IGenericPropertyEdge<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_Pipe1, _Pipe2); _Pipeline.SetSourceCollection(new List<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>() { _Marko }); int _Counter = 0; while (_Pipeline.MoveNext()) { var _Edge = _Pipeline.Current; Assert.IsTrue(_Edge.Id.Equals(8) || _Edge.Id.Equals(9)); Assert.IsTrue(_Edge.Label.Equals("created") || (((Double)_Edge.GetProperty("weight")) > 0.5 && _Edge.Label.Equals("knows"))); _Counter++; } Assert.AreEqual(2, _Counter); }
public void testOrPipeGraph() { // ./outE[@label='created' or @weight > 0.5] var _Graph = TinkerGraphFactory.CreateTinkerGraph(); var _Marko = _Graph.VertexById(1); var _Peter = _Graph.VertexById(6); var _Pipe0 = new OutEdgesPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe1 = new EdgeLabelFilterPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(v => v != "created"); var _Pipe2 = new EdgePropertyFilterPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>("weight", v => (0.5).Equals(v)); var _ORFilterPipe = new OrFilterPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>( new HasNextPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_Pipe1), new HasNextPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_Pipe2)); var _Pipeline = new Pipeline<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>, IGenericPropertyEdge<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_Pipe0, _ORFilterPipe); _Pipeline.SetSourceCollection(new List<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>() { _Marko, _Peter, _Marko }); var _Counter = 0; while (_Pipeline.MoveNext()) { var _Edge = _Pipeline.Current; Assert.IsTrue(_Edge.Id.Equals(8) || _Edge.Id.Equals(9) || _Edge.Id.Equals(12)); Assert.IsTrue(((Double)_Edge.GetProperty("weight")) > 0.5f || _Edge.Label.Equals("created")); _Counter++; } Assert.AreEqual(5, _Counter); }
public void testFutureFilterGraph() { // ./outE[@label='created']/inV[@name='lop']/../../@name var _Graph = TinkerGraphFactory.CreateTinkerGraph(); var _Marko = _Graph.VertexById(1); var _PipeA = new OutEdgesPipe <UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _PipeB = new EdgeLabelFilterPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(v => v != "created"); var _PipeC = new InVertexPipe <UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _PipeD = new VertexPropertyFilterPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>("name", v => v == "lop"); var _Pipe1 = new AndFilterPipe<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>( new HasNextPipe<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>( new Pipeline<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>, IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_PipeA, _PipeB, _PipeC, _PipeD))); var _Pipe2 = new PropertyPipe<String, Object>(Keys: "name"); var _Pipeline = new Pipeline<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>, String>(_Pipe1, _Pipe2); _Pipeline.SetSourceCollection(new List<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>() { _Marko }); var _Counter = 0; while (_Pipeline.MoveNext()) { var name = _Pipeline.Current; Assert.AreEqual("marko", name); _Counter++; } Assert.AreEqual(1, _Counter); }
public void testComplexTwoFutureFilterGraph() { // ./outE/inV/../../outE/../outE/inV/@name var _Graph = TinkerGraphFactory.CreateTinkerGraph(); var _Marko = _Graph.VertexById(1); var _PipeA = new OutEdgesPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _PipeB = new InVertexPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe1 = new OrFilterPipe<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>( new HasNextPipe<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>( new Pipeline<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>, IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_PipeA, _PipeB))); var _PipeC = new OutEdgesPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe2 = new OrFilterPipe<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>( new HasNextPipe<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>(_PipeC)); var _Pipe3 = new OutEdgesPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe4 = new InVertexPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe5 = new PropertyPipe<String, Object>(Keys: "name"); var _Pipeline = new Pipeline<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>, String>(_Pipe1, _Pipe2, _Pipe3, _Pipe4, _Pipe5); _Pipeline.SetSourceCollection(new List<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>() { _Marko }); var _Counter = 0; while (_Pipeline.MoveNext()) { var _Name = _Pipeline.Current; Assert.IsTrue(_Name.Equals("vadas") || _Name.Equals("lop") || _Name.Equals("josh")); _Counter++; } Assert.AreEqual(3, _Counter); }
public void testPathConstruction() { var _Graph = TinkerGraphFactory.CreateTinkerGraph(); var _Marko = _Graph.VertexById(1); var _Pipe1 = new OutEdgesPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe2 = new InVertexPipe<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>(); var _Pipe3 = new PropertyPipe<String, Object>(Keys: "name"); _Pipe3.SetSource(_Pipe2); _Pipe2.SetSource(_Pipe1); var _MarkoList = new List<IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>>() { _Marko }; _Pipe1.SetSource(_MarkoList.GetEnumerator()); foreach (var _Name in _Pipe3) { var path = _Pipe3.Path; Assert.AreEqual(_Marko, path[0]); Assert.AreEqual(typeof(IGenericPropertyEdge<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>), path[1].GetType()); Assert.AreEqual(typeof(IGenericPropertyVertex<UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object, UInt64, Int64, String, String, Object>), path[2].GetType()); Assert.AreEqual(typeof(String), path[3].GetType()); if (_Name == "vadas") { Assert.AreEqual(_Graph.EdgeById(7), path[1]); Assert.AreEqual(_Graph.VertexById(2), path[2]); Assert.AreEqual("vadas", path[3]); } else if (_Name == "lop") { Assert.AreEqual(_Graph.EdgeById(9), path[1]); Assert.AreEqual(_Graph.VertexById(3), path[2]); Assert.AreEqual("lop", path[3]); } else if (_Name == "josh") { Assert.AreEqual(_Graph.EdgeById(8), path[1]); Assert.AreEqual(_Graph.VertexById(4), path[2]); Assert.AreEqual("josh", path[3]); } else Assert.Fail(); } }
//#region (static) StartMonoCSharpREPLShell(Args) ///// <summary> ///// The Mono C# REPL Shell ///// </summary> //public static void StartMonoCSharpREPLShell(params String[] Args) //{ // #region Feel free to step through... // _Compiler = new Runner(); // var a = _Compiler.Execute("Math.Abs(-42);"); // var b = _Compiler.Execute("Math.Sin(Math.PI / 6);"); // var c = _Compiler.Execute("class Fact { public int Run(int n) { return n <= 0 ? 1 : n*Run(n-1); } }"); // var d = _Compiler.Execute("new Fact().Run(5);"); // var e = _Compiler.Execute("\"abcdefgh\".Substring(1, 2);"); // var f = _Compiler.Execute("class Echo { public Object Print(Object o) { return o; } }"); // var g = _Compiler.Execute("var test = 123;"); // var h = _Compiler.Execute("new Echo().Print(test);"); // #endregion // #region Start the interactive (read-eval-print loop) shell... // var _Report = new Report(new ConsoleReportPrinter()); // var _CLP = new CommandLineParser(_Report); // _CLP.UnknownOptionHandler += Mono.Driver.HandleExtraArguments; // var _Settings = _CLP.ParseArguments(Args); // if (_Settings == null || _Report.Errors > 0) // Environment.Exit(1); // var _Evaluator = new Evaluator(_Settings, _Report) // { // InteractiveBaseClass = typeof(InteractiveBaseShell), // DescribeTypeExpressions = true // }; // //// Adding a assembly twice will lead to delayed errors... // //_Evaluator.ReferenceAssembly(typeof(YourAssembly).Assembly); // _Evaluator.ReferenceAssembly(typeof(Bragi).Assembly); // _Evaluator.ReferenceAssembly(typeof(IPropertyGraph).Assembly); // _Evaluator.ReferenceAssembly(typeof(GraphFactory).Assembly); // var u1 = _Compiler.Execute("using de.ahzf.Bragi;"); // var u2 = _Compiler.Execute("using de.ahzf.Blueprints;"); // var u3 = _Compiler.Execute("using de.ahzf.Balder.PropertyGraphs;"); // var u4 = _Compiler.Execute("using de.ahzf.Balder.PropertyGraphs.InMemory"); // var _CSharpShell = new CSharpShell(_Evaluator, "BragiShell").Run(); // #endregion //} //#endregion /// <summary> /// Main... /// </summary> /// <param name="Args">Arguments...</param> public static void Main(String[] Args) { var _graph = DemoGraphFactory.CreateSimpleGraph(); var Alice = _graph.VertexById("Alice").AsMutable(); var _Pipe1 = new OutEdgesPipe<String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object>(); var _Pipe2 = new InVertexPipe<String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object>(); var _Pipe3 = new PathPipe<IReadOnlyGenericPropertyVertex<String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object>>(); var _Pipeline = new Pipeline<IReadOnlyGenericPropertyVertex<String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object>, IEnumerable<Object>>(_Pipe1, _Pipe2, _Pipe3); _Pipeline.SetSource(new SingleEnumerator<IReadOnlyGenericPropertyVertex<String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object>>(Alice)); var x1 = _Pipeline.Select(path => path.Select(q => ((IIdentifier<String>)q).Id).Aggregate((a, b) => a + "|" + b)); var x2 = Alice.OutE().InV().Paths().ToArray(); foreach (var _Path in x1) { //var a0 = _Path.ElementAt(0); //var b0 = _Path.ElementAt(1) is IReadOnlyGenericPropertyEdge <String, Int64, String, String, Object, // String, Int64, String, String, Object, // String, Int64, String, String, Object, // String, Int64, String, String, Object>; //var c0 = _Path.ElementAt(2) is IReadOnlyGenericPropertyVertex<String, Int64, String, String, Object, // String, Int64, String, String, Object, // String, Int64, String, String, Object, // String, Int64, String, String, Object>; } Sigma_js.Start(); //Transactions.Start(); //NotificationsDemo.Start(); //Vanaheimr.Start(); //MulticastDemo.Start(); //PartitionGraphs.Start(); //TraversalGraphs.Start(); //NetworkingDemo.Start(); //TagExample.Start(); //PolyfileReader.Start(); //StartMonoCSharpREPLShell(); // Try to type: // "using de.ahzf.Bragi;" // // and then one of the following... // // "TagExample.Start();" // "ConcurrencyDemo.Start();" // "NetworkingDemo.Start();" // "SmallBenchmark.Start();" }