public void ChangedFiredAfterAddVertexToSubGraph() { var subgraph = new SubGraph<Model>(); this.graph.AddSubGraph(subgraph); this.graphChangedCalled = 0; subgraph.AddVertex(new Model()); Assert.AreEqual(1, this.graphChangedCalled); }
public MainWindowViewModel() { //load dot file var parser = Dot.AntlrParser.AntlrParserAdapter<string>.GetParser(); var dotFileReader = new StreamReader(@"D:\Github\LiveActive\SmartAnalyzer\Projects\callgraph.dot"); var result = parser.Parse(dotFileReader); // if (result != null) // this.Graph = result; var graph = new Graph<Person>(); var a = new Person(graph) { Name = "Jonh", Avatar = "./Avatars/avatar1.jpg" }; var b = new Person(graph) { Name = "Michael", Avatar = "./Avatars/avatar2.gif" }; var c = new Person(graph) { Name = "Kenny" }; var d = new Person(graph) { Name = "Lisa" }; var e = new Person(graph) { Name = "Lucy", Avatar = "./Avatars/avatar3.jpg" }; var f = new Person(graph) { Name = "Ted Mosby" }; var g = new Person(graph) { Name = "Glen" }; var h = new Person(graph) { Name = "Alice", Avatar = "./Avatars/avatar1.jpg" }; graph.AddVertex(a); graph.AddVertex(b); graph.AddVertex(c); graph.AddVertex(d); graph.AddVertex(e); graph.AddVertex(f); var subGraph = new SubGraph<Person> { Label = "Work" }; graph.AddSubGraph(subGraph); subGraph.AddVertex(g); subGraph.AddVertex(h); graph.AddEdge(new Edge<Person>(g, h)); graph.AddEdge(new Edge<Person>(a, g)); var subGraph2 = new SubGraph<Person> {Label = "School"}; graph.AddSubGraph(subGraph2); var loner = new Person(graph) { Name = "Loner", Avatar = "./Avatars/avatar1.jpg" }; subGraph2.AddVertex(loner); graph.AddEdge(new Edge<SubGraph<Person>>(subGraph, subGraph2) { Label = "Link between groups" } ); graph.AddEdge(new Edge<Person>(c, d) { Label = "In love", DestinationArrowLabel = "boyfriend", SourceArrowLabel = "girlfriend" }); graph.AddEdge(new Edge<Person>(c, g, new Arrow(), new Arrow())); graph.AddEdge(new Edge<Person>(c, a, new Arrow()) { Label = "Boss" }); graph.AddEdge(new Edge<Person>(d, h, new DiamondArrow(), new DiamondArrow())); graph.AddEdge(new Edge<Person>(f, h, new DiamondArrow(), new DiamondArrow())); graph.AddEdge(new Edge<Person>(f, loner, new DiamondArrow(), new DiamondArrow())); graph.AddEdge(new Edge<Person>(f, b, new DiamondArrow(), new DiamondArrow())); graph.AddEdge(new Edge<Person>(e, g, new Arrow(), new Arrow()) { Label = "Siblings" }); this.Graph = graph; this.Graph.Changed += GraphChanged; this.NewPersonName = "Enter new name"; this.UpdatePersonNewName = "Enter new name"; }
public void SetUp() { this.graph = new Graph<string>(); this.graph.AddVertex("a"); this.graph.AddVertex("b"); var subGraph = new SubGraph<string>(); this.graph.AddSubGraph(subGraph); subGraph.AddVertex("c"); this.graph.AddEdge(new Edge<string>("a", "b")); this.graph.AddEdge(new Edge<string>("b", "c")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testEscapingOfNodeStringArrayPropertyValue() public virtual void TestEscapingOfNodeStringArrayPropertyValue() { Node n = _gdb.createNode(); n.SetProperty("name", new string[] { "Brutus \"Brutal\" Howell", "Dr." }); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cypher.internal.javacompat.ExecutionResult result = result("node", n); ExecutionResult result = result("node", n); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final SubGraph graph = CypherResultSubGraph.from(result, gdb, false); SubGraph graph = CypherResultSubGraph.From(result, _gdb, false); assertEquals("create (_" + n.Id + " {`name`:[\"Brutus \\\"Brutal\\\" Howell\", \"Dr.\"]})" + lineSeparator() + ";" + lineSeparator(), DoExportGraph(graph)); }
public void TestGraphRootSource() { var data = MakeGraphPair(new EntityBinaryGraphFactory(), new ThingGraph()); IGraph <IGraphEntity, IGraphEdge> graph = new SubGraph <IGraphEntity, IGraphEdge> (data, new Graph <IGraphEntity, IGraphEdge>()); var args = graph.RootSink().GraphPairTypes(); if (args != null) { ReportDetail("IGraphPair<{0},{1},{2},{3}>", args[0], args[1], args[2], args[3]); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testEscapingStringPropertyWithBackslash() public virtual void TestEscapingStringPropertyWithBackslash() { Node n = _gdb.createNode(); n.SetProperty("name", "Some\\thing"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cypher.internal.javacompat.ExecutionResult result = result("node", n); ExecutionResult result = result("node", n); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final SubGraph graph = CypherResultSubGraph.from(result, gdb, false); SubGraph graph = CypherResultSubGraph.From(result, _gdb, false); assertEquals("create (_" + n.Id + " {`name`:\"Some\\\\thing\"})" + lineSeparator() + ";" + lineSeparator(), DoExportGraph(graph)); }
public void EdgeNotInView() { var source = new Graph <IGraphEntity, IGraphEdge> (); var sink = new Graph <IGraphEntity, IGraphEdge>(); var subGraph = new SubGraph <IGraphEntity, IGraphEdge> (source, sink); var one = new GraphEntity <string> ("1"); var two = new GraphEntity <string>("2"); var three = new GraphEntity <string>("3"); source.Add(one); source.Add(two); source.Add(three); var link = new GraphEdge(one, two); var linklink = new GraphEdge(link, three); source.Add(linklink); sink.Add(one); sink.Add(two); sink.Add(link); Assert.IsTrue(source.Contains(link), "source has to contain link"); Assert.IsTrue(source.Contains(linklink), "source has to contain linklink"); Assert.IsFalse(sink.Contains(linklink), "sink must not contain linklink"); Assert.IsFalse(subGraph.Contains(linklink), "subGraph must not contain linklink"); sink.Add(linklink); sink.Remove(link); Assert.IsFalse(subGraph.Contains(linklink), "subGraph must not contain linklink"); sink.Add(link); foreach (var edge in subGraph.Fork(three)) { Assert.IsFalse(edge.Equals(linklink), "subGraph must not contain linklink"); } bool found = false; foreach (var edge in source.Fork(three)) { if (edge == linklink) { found = true; break; } } Assert.IsTrue(found, "source.fork has to contain linklink"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testFromRelCypherResult() public virtual void TestFromRelCypherResult() { Node n = _gdb.createNode(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Relationship rel = n.createRelationshipTo(n, org.neo4j.graphdb.RelationshipType.withName("REL")); Relationship rel = n.CreateRelationshipTo(n, RelationshipType.withName("REL")); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cypher.internal.javacompat.ExecutionResult result = result("rel", rel); ExecutionResult result = result("rel", rel); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final SubGraph graph = CypherResultSubGraph.from(result, gdb, true); SubGraph graph = CypherResultSubGraph.From(result, _gdb, true); assertEquals("create (_0)" + lineSeparator() + "create (_0)-[:`REL`]->(_0)" + lineSeparator() + ";" + lineSeparator(), DoExportGraph(graph)); }
public void Considers_Subgraph_unequal_when_runtime_types_should_be_checked( string graphId, DotNode dotNode1, DotNode dotNode2) { var graph1 = new SubGraph(graphId); graph1.Elements.Add(dotNode1); var graph2 = new SubGraph(graphId); graph2.Elements.Add(dotNode2); graph1.Should().NotBeEquivalentTo(graph2, options => options.RespectingRuntimeTypes()); }
public void SubGraphAsGraphPairTest() { var source = new Graph <IGraphEntity, IGraphEdge>(); var sink = new Graph <IGraphEntity, IGraphEdge>(); var subGraph = new SubGraph <IGraphEntity, IGraphEdge>(source, sink); var subGraph2 = new SubGraph <IGraphEntity, IGraphEdge>(subGraph, sink); var result = subGraph.RootSource(); Assert.AreSame(subGraph, result); result = subGraph2.RootSource(); Assert.AreSame(subGraph, result); }
/// <summary> /// creates a ThingGraphView with only the things that are in the scene /// </summary> /// <param name="scene"></param> /// <returns></returns> public virtual SubGraph <IThing, ILink> CreateThingsView(IGraphScene <IVisual, IVisualEdge> scene) { var graph = scene.Graph.Source <IVisual, IVisualEdge, IThing, ILink> (); if (graph == null) { return(null); } var thingView = new SubGraph <IThing, ILink> (graph.Source as IThingGraph, new ThingGraph()); thingView.AddRange(scene.Elements.Select(v => graph.Get(v))); return(thingView); }
private Task <SubGraph> GetCalculationTask(SubGraph p) { Task <SubGraph> calculationTask = Task.Factory.StartNew((arg) => { SubGraph subGraph = (SubGraph)arg; for (int i = 0; i < subGraph.Nodes.Count; i++) { CheckForDominance(subGraph.Nodes[i]); GenerateStateListFromNode(subGraph.Nodes[i], subGraph); } return(subGraph); }, p); return(calculationTask); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testSingleNodeWithArrayProperties() public virtual void TestSingleNodeWithArrayProperties() { Node n = _gdb.createNode(); n.SetProperty("name", new string[] { "a", "b" }); n.SetProperty("age", new int[] { 1, 2 }); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cypher.internal.javacompat.ExecutionResult result = result("node", n); ExecutionResult result = result("node", n); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final SubGraph graph = CypherResultSubGraph.from(result, gdb, false); SubGraph graph = CypherResultSubGraph.From(result, _gdb, false); assertEquals("create (_" + n.Id + " {`age`:[1, 2], `name`:[\"a\", \"b\"]})" + lineSeparator() + ";" + lineSeparator(), DoExportGraph(graph)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testSingleNodeLabels() public virtual void TestSingleNodeLabels() { Node n = _gdb.createNode(); n.AddLabel(Label.label("Foo")); n.AddLabel(Label.label("Bar")); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cypher.internal.javacompat.ExecutionResult result = result("node", n); ExecutionResult result = result("node", n); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final SubGraph graph = CypherResultSubGraph.from(result, gdb, false); SubGraph graph = CypherResultSubGraph.From(result, _gdb, false); assertEquals("create (_" + n.Id + ":`Foo`:`Bar`)" + lineSeparator() + ";" + lineSeparator(), DoExportGraph(graph)); }
public void SimpleSubGraph() { var g = new Graph(); g.Nodes.Add("1"); g.Nodes.Add("2"); g.Nodes.Add("3"); var subGraph = new SubGraph(g.Nodes["1"], g.Nodes["2"]); g.SubGraphs.Add(subGraph); Assert.Single(g.Nodes["1"].SubGraphs, subGraph); Assert.Single(g.Nodes["2"].SubGraphs, subGraph); Assert.Empty(g.Nodes["3"].SubGraphs); }
public void RemoveNodeFromGraph() { var g = new Graph(); var n1 = g.Nodes.Add("1"); var n2 = g.Nodes.Add("2"); g.Nodes.Add("3"); var subGraph = new SubGraph(n1, n2); g.SubGraphs.Add(subGraph); g.Nodes.Remove(n1); Assert.Empty(n1.SubGraphs); Assert.Single(subGraph.Nodes, n2); }
public MainWindowViewModel() { var graph = new Graph<Person>(); var a = new Person(graph) { Name = "Jonh", Avatar = "./Avatars/avatar1.jpg" }; var b = new Person(graph) { Name = "Michael", Avatar = "./Avatars/avatar2.gif" }; var c = new Person(graph) { Name = "Kenny" }; var d = new Person(graph) { Name = "Lisa" }; var e = new Person(graph) { Name = "Lucy", Avatar = "./Avatars/avatar3.jpg" }; var f = new Person(graph) { Name = "Ted Mosby" }; var g = new Person(graph) { Name = "Glen" }; var h = new Person(graph) { Name = "Alice", Avatar = "./Avatars/avatar1.jpg" }; graph.AddVertex(a); graph.AddVertex(b); graph.AddVertex(c); graph.AddVertex(d); graph.AddVertex(e); graph.AddVertex(f); var subGraph = new SubGraph<Person> { Label = "Work" }; graph.AddSubGraph(subGraph); subGraph.AddVertex(g); subGraph.AddVertex(h); graph.AddEdge(new Edge<Person>(g, h)); graph.AddEdge(new Edge<Person>(a, g)); var subGraph2 = new SubGraph<Person> {Label = "School"}; graph.AddSubGraph(subGraph2); var loner = new Person(graph) { Name = "Loner", Avatar = "./Avatars/avatar1.jpg" }; subGraph2.AddVertex(loner); graph.AddEdge(new Edge<SubGraph<Person>>(subGraph, subGraph2) { Label = "Link between groups" } ); graph.AddEdge(new Edge<Person>(c, d) { Label = "In love", DestinationArrowLabel = "boyfriend", SourceArrowLabel = "girlfriend" }); graph.AddEdge(new Edge<Person>(c, g, new Arrow(), new Arrow())); graph.AddEdge(new Edge<Person>(c, a, new Arrow()) { Label = "Boss" }); graph.AddEdge(new Edge<Person>(d, h, new DiamondArrow(), new DiamondArrow())); graph.AddEdge(new Edge<Person>(f, h, new DiamondArrow(), new DiamondArrow())); graph.AddEdge(new Edge<Person>(f, loner, new DiamondArrow(), new DiamondArrow())); graph.AddEdge(new Edge<Person>(f, b, new DiamondArrow(), new DiamondArrow())); graph.AddEdge(new Edge<Person>(e, g, new Arrow(), new Arrow()) { Label = "Siblings" }); this.Graph = graph; this.Graph.Changed += GraphChanged; this.NewPersonName = "Enter new name"; this.UpdatePersonNewName = "Enter new name"; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testEscapingOfRelationshipStringArrayPropertyValue() public virtual void TestEscapingOfRelationshipStringArrayPropertyValue() { Node n = _gdb.createNode(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Relationship rel = n.createRelationshipTo(n, org.neo4j.graphdb.RelationshipType.withName("REL")); Relationship rel = n.CreateRelationshipTo(n, RelationshipType.withName("REL")); rel.SetProperty("name", new string[] { "Brutus \"Brutal\" Howell", "Dr." }); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cypher.internal.javacompat.ExecutionResult result = result("rel", rel); ExecutionResult result = result("rel", rel); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final SubGraph graph = CypherResultSubGraph.from(result, gdb, true); SubGraph graph = CypherResultSubGraph.From(result, _gdb, true); assertEquals("create (_0)" + lineSeparator() + "create (_0)-[:`REL` {`name`:[\"Brutus \\\"Brutal\\\" Howell\", \"Dr.\"]}]->(_0)" + lineSeparator() + ";" + lineSeparator(), DoExportGraph(graph)); }
public void TestCreateNestedStructures() { // Documentation: // Subgraphs are an important construct in Cgraph.They are intended for organizing subsets of // graph objects and can be used interchangeably with top - level graphs in almost all Cgraph // functions. A subgraph may contain any nodes or edges of its parent. (When an edge is // inserted in a subgraph, its nodes are also implicitly inserted if necessary.Similarly, // insertion of a node or edge automatically implies insertion in all containing subgraphs up // to the root.) Subgraphs of a graph form a hierarchy(a tree).Cgraph has functions to // create, search, and iterate over subgraphs. // Conclusion: the hierarchical tree structure is maintained in a sane way across all // operations we can do w.r.t. subgraphs. // If a node is created in a subgraph, it should also be contained in all supergraphs RootGraph graph = Utils.CreateUniqueTestGraph(); SubGraph supergraph = graph.GetOrAddSubgraph("level 1"); string subgraphname = "level 2"; SubGraph subgraph = supergraph.GetOrAddSubgraph(subgraphname); string nodename = "test node"; Node node = subgraph.GetOrAddNode(nodename); // Node must be contained in super graph Assert.True(node.MyRootGraph.Equals(graph)); Assert.True(supergraph.Contains(node)); Assert.True(supergraph.Nodes().Contains(node)); Assert.NotNull(supergraph.GetNode(nodename)); // Node must be contained in root graph Assert.True(graph.Contains(node)); Assert.True(graph.Nodes().Contains(node)); Assert.NotNull(graph.GetNode(nodename)); // Subgraph must be contained in super graph Assert.True(supergraph.Contains(subgraph)); Assert.True(supergraph.Descendants().Contains(subgraph)); Assert.NotNull(supergraph.GetSubgraph(subgraphname)); // Subgraph must be contained in root graph Assert.True(graph.Contains(subgraph)); Assert.True(graph.Descendants().Contains(subgraph)); // Subgraph cannot be obtained in the following way: //graph.GetSubgraph(subgraphname) Assert.Null(graph.GetSubgraph(subgraphname)); // Use a utility function instead: Assert.NotNull(graph.GetDescendantByName(subgraphname)); }
public void PushNodesToClusters() { var g = new Graph(); var c = new SubGraph { Code = "cluster_0" }; var n = new Node { Code = "x", SubgraphCode = "cluster_0" }; g.Nodes.Add(n); g.SubGraphs.Add(c); g.AutoTune(); Assert.True(c.Nodes.Contains(n)); Assert.True(n.Parent == c); Console.WriteLine(GraphRender.Render(g)); }
private void TestSubGraph(Graph <IVertice> graph) { var g = new LogItemVetice(graph); var h = new LogItemVetice(graph); var subGraph = new SubGraph <IVertice> { Label = "Work" }; graph.AddSubGraph(subGraph); subGraph.AddVertex(g); subGraph.AddVertex(h); this.Graph = graph; this.Graph.Changed += GraphChanged; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testExportConstraintsViaCypherResult() public virtual void TestExportConstraintsViaCypherResult() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Label label = org.neo4j.graphdb.Label.label("Foo"); Label label = Label.label("Foo"); _gdb.schema().constraintFor(label).assertPropertyIsUnique("bar").create(); _gdb.schema().constraintFor(label).assertPropertyIsUnique("bar2").create(); CommitAndStartNewTransactionAfterSchemaChanges(); Node n = _gdb.createNode(label); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cypher.internal.javacompat.ExecutionResult result = result("node", n); ExecutionResult result = result("node", n); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final SubGraph graph = CypherResultSubGraph.from(result, gdb, true); SubGraph graph = CypherResultSubGraph.From(result, _gdb, true); assertEquals("create constraint on (n:`Foo`) assert n.`bar2` is unique;" + lineSeparator() + "create constraint on (n:`Foo`) assert n.`bar` is unique;" + lineSeparator() + "create (_0:`Foo`)" + lineSeparator() + ";" + lineSeparator(), DoExportGraph(graph)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testFromPathCypherResult() public virtual void TestFromPathCypherResult() { Node n1 = _gdb.createNode(); Node n2 = _gdb.createNode(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Relationship rel = n1.createRelationshipTo(n2, org.neo4j.graphdb.RelationshipType.withName("REL")); Relationship rel = n1.CreateRelationshipTo(n2, RelationshipType.withName("REL")); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Path path = new org.neo4j.graphalgo.impl.util.PathImpl.Builder(n1).push(rel).build(); Path path = (new PathImpl.Builder(n1)).push(rel).build(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cypher.internal.javacompat.ExecutionResult result = result("path", path); ExecutionResult result = result("path", path); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final SubGraph graph = CypherResultSubGraph.from(result, gdb, true); SubGraph graph = CypherResultSubGraph.From(result, _gdb, true); assertEquals("create (_0)" + lineSeparator() + "create (_1)" + lineSeparator() + "create (_0)-[:`REL`]->(_1)" + lineSeparator() + ";" + lineSeparator(), DoExportGraph(graph)); }
public override void Calculate() { if (!Graph.CanCalculateParallel) { return; } GeneratedDuties = new List <Duty>(); _calculationTasks = new List <Task <SubGraph> >(); //set event handlers SetCalculationNotifications(true); GetFirstNodeState(Graph.StartNode); //Start first Path SubGraph firstPath = Graph.SubGraphs.Single((x) => x.Nodes.Contains(Graph.StartNode)); _calculationTasks.Add(GetCalculationTask(firstPath)); //WaitAllOneByOne while (_calculationTasks.Count > 0) { //logger.Info("Tasks: " + CalculationTasks.Count.ToString(),"Solver"); Options.DEBUG_MAX_PARALLEL = Math.Max(_calculationTasks.Count, Options.DEBUG_MAX_PARALLEL); int idx = Task.WaitAny(_calculationTasks.ToArray()); if (_calculationTasks[idx].Exception != null) { HandleAe(_calculationTasks[idx].Exception); } SubGraph completedPath = _calculationTasks[idx].Result; _calculationTasks.RemoveAt(idx); //reduce results: [warum das hier und nicht schon im pfad processing?] for (int i = 0; i < completedPath.StateCollector.Count; i++) { completedPath.StateCollector[i].AssignToNode(); } //notify completion completedPath.OnCalculationComplete(); } //Last Node GetDuties(Graph.EndNode); //detach eventhandlers SetCalculationNotifications(false); Graph.NeedsCalculation = false; }
public void AddNodeFromOtherGraph() { var g = new Graph(); g.Nodes.Add("1"); g.Nodes.Add("2"); g.Nodes.Add("3"); var h = new Graph(); h.Nodes.Add("4"); Assert.Throws <ArgumentException>(() => new SubGraph(g.Nodes["1"], h.Nodes["4"])); Assert.Throws <ArgumentException>(() => { var subGraph = new SubGraph(g.Nodes["1"]); subGraph.Nodes.Add(h.Nodes["4"]); }); }
public void NamedSubGraphs(bool directed) { var g = new Graph(directed); g.Nodes.Add("A"); g.Nodes.Add("B"); g.Nodes.Add("C"); g.Edges.Add("A", "B"); g.Edges.Add("B", "C"); g.Edges.Add("C", "A"); var subGraph = new SubGraph("H", g.Nodes["A"], g.Nodes["B"]); subGraph.UserData["color"] = "red"; g.SubGraphs.Add(subGraph); Validate(g, true, true); }
public void Considers_Subgraph_equivalent_even_when_elements_are_different( string graphId, DotNode dotNode1, DotNode dotNode2) { var graph1 = new SubGraph(graphId); graph1.Elements.Add(dotNode1); var graph2 = new SubGraph(graphId); graph2.Elements.Add(dotNode2); using var a = new AssertionScope(); graph1.Should().BeEquivalentTo(graph2); var cluster = graph1.Elements.First() as DotNode; var cluster2 = graph2.Elements.First() as DotNode; cluster.Should().NotBeEquivalentTo(cluster2); }
private void Update(EvaluationContext context) { // string variableName = Variable.GetValue(context); // float end = End.GetValue(context); // for (float i = 0f; i < end; i += 1.0f) // { // context.FloatVariables[variableName] = i; // // DirtyFlag.InvalidationRefFrame++; // Command.Invalidate(); // Command.GetValue(context); // } var name = VariableName.GetValue(context); var newValue = Value.GetValue(context); if (string.IsNullOrEmpty(name)) { Log.Warning($"Can't set variable with invalid name {name}"); return; } if (!SubGraph.IsConnected) { context.FloatVariables[name] = newValue; } else { var previous = 0f; var hadPreviousValue = context.FloatVariables.TryGetValue(name, out previous); context.FloatVariables[name] = newValue; SubGraph.GetValue(context); if (hadPreviousValue) { context.FloatVariables[name] = newValue; } else { context.FloatVariables.Remove(name); } } }
void Awake() { m_VertexIdToLocalIndex = new NativeHashMap <int, int>(m_GlobalVertexCount, Allocator.Persistent); m_Graph = new Graph(m_GlobalVertexCount, m_EdgeCount); TestUtils.GenerateGraphInput(m_Graph.Edges, m_GlobalVertexCount); // this next block is all just validating the graph itself, as in the graph init test Assert.IsTrue(m_Graph.Edges.IsCreated); Assert.AreEqual(m_EdgeCount, m_Graph.Edges.Length); foreach (var edge in m_Graph.Edges) { Assert.IsTrue(edge.x >= 0); Assert.IsTrue(edge.y >= 0); Assert.IsTrue(edge.x < m_GlobalVertexCount); Assert.IsTrue(edge.y < m_GlobalVertexCount); Assert.AreNotEqual(edge.x, edge.y); } // now we'll actually test initializing the subgraph of this graph m_Edges = TestUtils.RandomSubGraph(m_Graph, m_SubGraphEdgeCount, out s_SubGraphVertexSet); var subVertexArray = s_SubGraphVertexSet.ToArray(); m_SubGraphOne = new SubGraph(subVertexArray, m_Edges); var subGraphEdges = m_SubGraphOne.EdgesByLocalIndex; Assert.IsTrue(subGraphEdges.IsCreated); Assert.AreEqual(m_SubGraphEdgeCount, subGraphEdges.Length); m_InitJob = new InitializeSubGraphArrayJob() { InputEdgesAsIDs = m_Edges, EdgesAsIndices = m_SubGraphOne.EdgesByLocalIndex, VertexIDs = m_SubGraphOne.VertexIds, VertexIdToIndex = m_VertexIdToLocalIndex }; m_InitJobHandle = m_InitJob.Schedule(); }
public void Clusters() { RootGraph root = RootGraph.CreateNew("Graph with clusters", GraphType.Directed); Node nodeA = root.GetOrAddNode("A"); Node nodeB = root.GetOrAddNode("B"); Node nodeC = root.GetOrAddNode("C"); Node nodeD = root.GetOrAddNode("D"); // When a subgraph name is prefixed with cluster, // the dot layout engine will render it as a box around the containing nodes. SubGraph cluster1 = root.GetOrAddSubgraph("cluster_1"); cluster1.AddExisting(nodeB); cluster1.AddExisting(nodeC); SubGraph cluster2 = root.GetOrAddSubgraph("cluster_2"); cluster2.AddExisting(nodeD); // COMPOUND EDGES // Graphviz does not really support edges from and to clusters. However, by adding an // invisible dummynode and setting the ltail or lhead attributes of an edge this // behavior can be faked. Graphviz will then draw an edge to the dummy node but clip it // at the border of the cluster. We provide convenience methods for this. // To enable this feature, Graphviz requires us to set the "compound" attribute to "true". Graph.IntroduceAttribute(root, "compound", "true"); // Allow lhead/ltail // The boolean indicates whether the dummy node should take up any space. When you pass // false and you have a lot of edges, the edges may start to overlap a lot. _ = root.GetOrAddEdge(nodeA, cluster1, false, "edge to a cluster"); _ = root.GetOrAddEdge(cluster1, nodeD, false, "edge from a cluster"); _ = root.GetOrAddEdge(cluster1, cluster1, false, "edge between clusters"); root.ComputeLayout(); SubGraph cluster = root.GetSubgraph("cluster_1"); RectangleF clusterbox = cluster.BoundingBox(); RectangleF rootgraphbox = root.BoundingBox(); Utils.AssertPattern(@"{X=[\d.]+,Y=[\d.]+,Width=[\d.]+,Height=[\d.]+}", clusterbox.ToString()); Utils.AssertPattern(@"{X=[\d.]+,Y=[\d.]+,Width=[\d.]+,Height=[\d.]+}", rootgraphbox.ToString()); }
void Awake() { m_InputVertices = new NativeList <int>(m_SubGraphVertexCount, Allocator.Persistent); m_InputEdgesById = new NativeList <int2>(m_SubGraphEdgeCount, Allocator.Persistent); m_VertexIdToLocalIndex = new NativeHashMap <int, int>(m_SubGraphVertexCount, Allocator.Persistent); TestUtils.GenerateSubGraphInput(m_InputVertices, m_SubGraphVertexCount, m_GlobalVertexCount, m_InputEdgesById, m_SubGraphEdgeCount); m_SubGraphOne = new SubGraph(m_InputVertices, m_InputEdgesById); m_InitJob = new InitializeSubGraphJob() { InputVertices = m_InputVertices, InputEdgesAsIDs = m_InputEdgesById, EdgesAsIndices = m_SubGraphOne.EdgesByLocalIndex, VertexIDs = m_SubGraphOne.VertexIds, VertexIdToIndex = m_VertexIdToLocalIndex }; m_CreationJobHandle = m_InitJob.Schedule(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testFromSimpleGraph() public virtual void TestFromSimpleGraph() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Node n0 = gdb.createNode(); Node n0 = _gdb.createNode(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Node n1 = gdb.createNode(); Node n1 = _gdb.createNode(); n1.SetProperty("name", "Node1"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Relationship relationship = n0.createRelationshipTo(n1, org.neo4j.graphdb.RelationshipType.withName("REL")); Relationship relationship = n0.CreateRelationshipTo(n1, RelationshipType.withName("REL")); relationship.SetProperty("related", true); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final SubGraph graph = DatabaseSubGraph.from(gdb); SubGraph graph = DatabaseSubGraph.From(_gdb); assertEquals("create (_" + n0.Id + ")" + lineSeparator() + "create (_" + n1.Id + " {`name`:\"Node1\"})" + lineSeparator() + "create (_" + n0.Id + ")-[:`REL` {`related`:true}]->(_" + n1.Id + ")" + lineSeparator() + ";" + lineSeparator(), DoExportGraph(graph)); }
private void GenerateStateListFromNode(Node fromNode, SubGraph path) { for (int i = 0; i < fromNode.States.Count; i++) { for (int j = 0; j < fromNode.OutArcs.Count; j++) { NodeState newState; if (TryCreateNodeState(fromNode.States[i], fromNode.OutArcs[j], out newState)) { //assign the state to its node or collect the state for later assignment (due to concurrency) if (path.Nodes.Contains(newState.MyNode)) { newState.AssignToNode(); } else { path.StateCollector.Add(newState); } } } } }
public void TestRecursiveSubgraphDeletion() { RootGraph graph = Utils.CreateUniqueTestGraph(); Graph.IntroduceAttribute(graph, "label", ""); graph.SetAttribute("label", "xx"); Node node = graph.GetOrAddNode("node"); SubGraph subgraph = graph.GetOrAddSubgraph("subgraph"); subgraph.SetAttribute("label", "x"); Node subnode = subgraph.GetOrAddNode("subnode"); SubGraph subsubgraph = subgraph.GetOrAddSubgraph("subsubgraph"); subsubgraph.SetAttribute("label", "x"); Node subsubnode = subsubgraph.GetOrAddNode("subsubnode"); // Now deleting subgraph should also delete subsubgraph Assert.AreNotEqual(null, subgraph.GetSubgraph("subsubgraph")); Assert.AreNotEqual(null, graph.GetDescendantByName("subsubgraph")); subgraph.Delete(); Assert.AreEqual(null, graph.GetDescendantByName("subsubgraph")); }
public generagrafo() { var graph = new Graph<ElementoGrafo>(); var subgraph = new SubGraph<ElementoGrafo>() { Label = "Colectivo" }; var a = new ElementoGrafo(graph) { nombre = "pasaje", valor = 500 }; var b = new ElementoGrafo(graph) { nombre = "pasajeros", valor = 25 }; var c = new ElementoGrafo(graph) { nombre = "bencina", valor = 1000 }; graph.AddSubGraph(subgraph); subgraph.AddVertex(a); subgraph.AddVertex(b); graph.AddVertex(c); graph.AddEdge(new Edge<ElementoGrafo>(a, b)); graph.AddEdge(new Edge<ElementoGrafo>(c, b)); graph.AddEdge(new Edge<ElementoGrafo>(c, a)); this.Graph = graph; this.Graph.Changed += GraphChanged; }
private void CreateStatusBar() { #region Status Bar int index = 20; Panel statusPanel = new Panel(); statusPanel.ShowBackground = true; statusPanel.ShowBorder = false; statusPanel.Docking = System.Windows.Forms.DockStyle.Bottom; statusPanel.IsVisible = true; statusPanel.RelitiveZIndex = index++; statusPanel.Size = new System.Drawing.Size(152, 24); Controls.Add(statusPanel); index = 1; m_SpeedGraph = new MultiGraph(); m_SpeedGraph.Location = new System.Drawing.Point(2, 2); m_SpeedGraph.Size = new System.Drawing.Size(150, 20); m_SpeedGraph.IsVisible = true; m_SpeedGraph.RelitiveZIndex = index++; statusPanel.Controls.Add(m_SpeedGraph); m_FPSGraph = new SubGraph(150); m_FPSGraph.IsVisible = true; m_FPSGraph.LineColor = new SlimDX.Color4(0.75f, 0.3f, 1f, 0.3f); m_SpeedGraph.Graphs.Add(m_FPSGraph); m_FPSLabel = new DynamicLabel(); m_FPSLabel.ForeColor = new SlimDX.Color4(0.75f, 0.3f, 1f, 0.3f); m_FPSLabel.MaxLength = 16; m_FPSLabel.Location = new System.Drawing.Point(154, 0); m_FPSLabel.FixedSize = false; m_FPSLabel.FontType = FontType.Small; m_FPSLabel.TextAlign = System.Drawing.ContentAlignment.TopLeft; m_FPSLabel.IsVisible = true; m_FPSLabel.RelitiveZIndex = index++; statusPanel.Controls.Add(m_FPSLabel); #endregion }
public void CreateElemento(Elemento elemento, Nivel n) { if (this.nombreselementos.Any(x => x == elemento.nombre)) { // such a person already exists: there should be some validation message, but // it is not so important in a demo return; } var p = new ElementoGrafo(this.Graph) { nombre = elemento.nombre, valor = (int)elemento.valor }; int i = revisarsubgrafo(n); if (i != -1) { this.Graph.SubGraphs.ElementAt(i).AddVertex(p); } else { SubGraph<ElementoGrafo> sg2 = new SubGraph<ElementoGrafo>() { Label = n.nombre}; sg2.AddVertex(p); this.Graph.AddSubGraph(sg2); if (existeenotrosubgrafo(sg2.Label)) { createlink(sg2, buscarsubgrafo(n.nombre)); } } }
private void createlink(SubGraph<ElementoGrafo> sg2, SubGraph<ElementoGrafo> sg3) { this.Graph.AddEdge(new Edge<SubGraph<ElementoGrafo>>(sg2, sg3)); }
public override void Initiate() { int index = 1; Label label = new Label(); label.TextAlign = System.Drawing.ContentAlignment.TopLeft; label.FixedSize = true; label.Size = new System.Drawing.Size(this.Size.Width - 10, 30); label.Location = new System.Drawing.Point(0, 5); label.Text = "Ensemble Tests"; label.FontType = FontType.Heading; label.IsVisible = true; label.Padding = new System.Windows.Forms.Padding(5); label.RelitiveZIndex = index++; this.Controls.Add(label); int verticalOffset = 35; Button button = new Button(); button.Size = new System.Drawing.Size(this.Size.Width - 10, 20); button.Location = new System.Drawing.Point(5, verticalOffset); button.Text = "Start Tests"; button.FontType = FontType.Small; button.IsVisible = true; button.RelitiveZIndex = index++; button.Click += new EventHandler(button_Click); this.Controls.Add(button); verticalOffset += 25; m_ProgressBar = new ProgressBar(); m_ProgressBar.Size = new System.Drawing.Size(this.Size.Width - 10, 20); m_ProgressBar.Location = new System.Drawing.Point(5, verticalOffset); m_ProgressBar.IsVisible = true; m_ProgressBar.RelitiveZIndex = index++; m_ProgressBar.Value = 0; m_ProgressBar.MaxValue = 100; this.Controls.Add(m_ProgressBar); verticalOffset += 25; m_SpeedGraph = new MultiGraph(); m_SpeedGraph.Location = new System.Drawing.Point(5, verticalOffset); m_SpeedGraph.Size = new System.Drawing.Size(this.Size.Width - 40, 200); m_SpeedGraph.IsVisible = true; m_SpeedGraph.RelitiveZIndex = index++; this.Controls.Add(m_SpeedGraph); m_OrginalGraph = new SubGraph(100); m_OrginalGraph.IsVisible = true; m_OrginalGraph.LineColor = new SlimDX.Color4(1f, 1f, 0.3f, 0.3f); m_OrginalGraph.MaxValue = 0.1f; m_OrginalGraph.Scrolling = false; m_SpeedGraph.Graphs.Add(m_OrginalGraph); m_OptoGraph = new SubGraph(100); m_OptoGraph.IsVisible = true; m_OptoGraph.LineColor = new SlimDX.Color4(1f, 0.3f, 1f, 0.3f); m_OptoGraph.MaxValue = 0.1f; m_OptoGraph.Scrolling = false; m_SpeedGraph.Graphs.Add(m_OptoGraph); m_OptoGraph2 = new SubGraph(100); m_OptoGraph2.IsVisible = true; m_OptoGraph2.LineColor = new SlimDX.Color4(1f, 1f, 1f, 0.3f); m_OptoGraph2.MaxValue = 0.1f; m_OptoGraph2.Scrolling = false; m_SpeedGraph.Graphs.Add(m_OptoGraph2); m_GraphMax = new DynamicLabel(); m_GraphMax.TextAlign = System.Drawing.ContentAlignment.TopLeft; m_GraphMax.FixedSize = true; m_GraphMax.Size = new System.Drawing.Size(30, 15); m_GraphMax.Location = new System.Drawing.Point(this.Size.Width - 35, verticalOffset); m_GraphMax.MaxLength = 10; m_GraphMax.Text = "0"; m_GraphMax.FontType = FontType.Small; m_GraphMax.IsVisible = true; m_GraphMax.Padding = new System.Windows.Forms.Padding(5); m_GraphMax.RelitiveZIndex = index++; this.Controls.Add(m_GraphMax); m_GraphMin = new DynamicLabel(); m_GraphMin.TextAlign = System.Drawing.ContentAlignment.TopLeft; m_GraphMin.FixedSize = true; m_GraphMin.Size = new System.Drawing.Size(30, 15); m_GraphMin.Location = new System.Drawing.Point(this.Size.Width - 35, verticalOffset + 185); m_GraphMin.MaxLength = 10; m_GraphMin.Text = "0"; m_GraphMin.FontType = FontType.Small; m_GraphMin.IsVisible = true; m_GraphMin.Padding = new System.Windows.Forms.Padding(5); m_GraphMin.RelitiveZIndex = index++; this.Controls.Add(m_GraphMin); verticalOffset += 200; this.Size = new System.Drawing.Size(this.Size.Width, verticalOffset + 5); }