public void TestWriter1000NodeGraph() { graph = new Graph(); List <INode> nodes = new List <INode>(); for (int i = 0; i != 1000; ++i) { var node = new TesteSubNode2(); nodes.Add(node); graph.Add(node); } Assert.AreEqual(nodes.Count, graph.NodeCount); Assert.AreEqual(1000, graph.NodeCount); Random random = new Random(); for (int i = 0; i != 1000; ++i) { var index1 = random.Next(0, 1000); var index2 = random.Next(0, 1000); while (index2 == index1) { index2 = random.Next(0, 1000); } graph.ConnectNodeToWith(nodes[index1], nodes[index2], new Edge(new AttributePair <Double> { Name = "Weight", Attribute = random.Next(1, 600) })); } Assert.AreEqual(graph.AllEdges.Count, 1000); writer.Save("Large Graph.xml", graph); }
public void TestSaveGraphWithUnknownNode() { graph = new Graph(); var A = new TestSubNode() { Label = "A" }; var B = new Node() { Label = "B" }; var C = new Node() { Label = "C" }; var D = new TestSubNode() { Label = "D" }; var E = new TesteSubNode2() { Label = "E" }; graph.Add(A); graph.Add(B); graph.Add(C); graph.Add(D); graph.Add(E); graph.ConnectNodeToWith(A, B, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 8 })); graph.ConnectNodeToWith(A, D, new TestSubEdge(9)); graph.ConnectNodeToWith(A, E, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 4 })); graph.ConnectNodeToWith(B, C, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 1 })); graph.ConnectNodeToWith(C, B, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 2 })); graph.ConnectNodeToWith(C, D, new TestSubEdge(3)); graph.ConnectNodeToWith(D, C, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 2 })); graph.ConnectNodeToWith(D, E, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 7 })); graph.ConnectNodeToWith(E, C, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 1 })); writer.Save(graphExoticNodePath, graph); }
public void Initialize() { co = new ConnectivityObserver(); graph = new Graph(); var A = new TestSubNode() { Label = "A" }; var B = new Node() { Label = "B" }; var C = new Node() { Label = "C" }; var D = new TestSubNode() { Label = "D" }; var E = new TesteSubNode2() { Label = "E" }; E.DescriptiveAttributes["test"] = "test"; B["dummy"] = 15; C.DescriptiveAttributes["time"] = "NOthing"; A["3"] = 0.99; graph.Add(A); graph.Add(B); graph.Add(C); graph.Add(D); graph.Add(E); graph.ConnectNodeToWith(A, B, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 8 })); graph.ConnectNodeToWith(A, D, new TestSubEdge(9)); graph.ConnectNodeToWith(A, E, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 4 })); graph.ConnectNodeToWith(B, C, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 1 })); graph.ConnectNodeToWith(C, B, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 2 })); graph.ConnectNodeToWith(C, D, new TestSubEdge(3)); graph.ConnectNodeToWith(D, C, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 2 })); graph.ConnectNodeToWith(D, E, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 7 })); graph.ConnectNodeToWith(E, C, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 1 })); observers = new List <INode>(); observers.Add(B); observers.Add(C); }
public void TestWriteExtendableGraph() { graph = new Graph(); var A = new TestSubNode() { Label = "A" }; var B = new Node() { Label = "B" }; var C = new Node() { Label = "C" }; var D = new TestSubNode() { Label = "D" }; var E = new TesteSubNode2() { Label = "E" }; E.DescriptiveAttributes["test"] = "test"; B["dummy"] = 15; C.DescriptiveAttributes["time"] = "NOthing"; A["3"] = 0.99; graph.Add(A); graph.Add(B); graph.Add(C); graph.Add(D); graph.Add(E); graph.ConnectNodeToWith(A, B, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 8 })); graph.ConnectNodeToWith(A, D, new TestSubEdge(9)); graph.ConnectNodeToWith(A, E, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 4 })); graph.ConnectNodeToWith(B, C, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 1 })); graph.ConnectNodeToWith(C, B, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 2 })); graph.ConnectNodeToWith(C, D, new TestSubEdge(3)); graph.ConnectNodeToWith(D, C, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 2 })); graph.ConnectNodeToWith(D, E, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 7 })); graph.ConnectNodeToWith(E, C, new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 1 })); writer.Save(extendableGraphPath, graph); }