- Timestamp:
- 09/08/16 11:41:45 (8 years ago)
- Location:
- branches/symbreg-factors-2650/HeuristicLab.Tests/HeuristicLab.IGraph
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/symbreg-factors-2650/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphLayoutTest.cs
r14276 r14277 29 29 public class IGraphLayoutTest { 30 30 [TestMethod] 31 public void TestFruchtermanReingold() { 31 [TestCategory("ExtLibs")] 32 [TestCategory("ExtLibs.igraph")] 33 [TestProperty("Time", "short")] 34 public void IGraphWrappersLayoutFruchtermanReingoldTest() { 32 35 var graph = new Graph(5, new[] { 33 36 Tuple.Create(0, 1), -
branches/symbreg-factors-2650/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersGraphTest.cs
r14276 r14277 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.IGraph.Wrappers; … … 27 28 namespace HeuristicLab.Tests { 28 29 [TestClass] 30 [DeploymentItem("igraph-0.8.0-pre-x86.dll")] 31 [DeploymentItem("igraph-0.8.0-pre-x64.dll")] 29 32 public class IGraphWrappersGraphTest { 30 33 [TestMethod] 31 public void IGraphWrappersGraphConstructionAndFinalization() { 34 [TestCategory("ExtLibs")] 35 [TestCategory("ExtLibs.igraph")] 36 [TestProperty("Time", "short")] 37 public void IGraphWrappersGraphConstructionAndFinalizationTest() { 32 38 var graph = new Graph(5, new[] { 33 39 Tuple.Create(0, 1), … … 51 57 52 58 [TestMethod] 53 public void TestDensity() { 59 [TestCategory("ExtLibs")] 60 [TestCategory("ExtLibs.igraph")] 61 [TestProperty("Time", "short")] 62 public void IGraphWrappersGraphDensityTest() { 54 63 var graph = new Graph(5, new[] { 55 64 Tuple.Create(0, 1), … … 82 91 83 92 [TestMethod] 84 public void TestPageRank() { 93 [TestCategory("ExtLibs")] 94 [TestCategory("ExtLibs.igraph")] 95 [TestProperty("Time", "short")] 96 public void IGraphWrappersGraphPageRankTest() { 85 97 var graph = new Graph(4, new[] { 86 98 Tuple.Create(0, 1), … … 125 137 Assert.AreEqual(0.173, ranks[3], 0.01); 126 138 } 139 140 [TestMethod] 141 [TestCategory("ExtLibs")] 142 [TestCategory("ExtLibs.igraph")] 143 [TestProperty("Time", "short")] 144 public void IGraphWrappersGraphBreadthFirstWalkTest() { 145 var graph = new Graph(4, new[] { 146 Tuple.Create(0, 1), 147 Tuple.Create(0, 2), 148 Tuple.Create(1, 2), 149 Tuple.Create(2, 0), 150 Tuple.Create(3, 2), 151 }, directed: true); 152 var visited = new HashSet<int>(); 153 BreadthFirstHandler handler = (graph1, currentVertexId, previousVertexId, nextVertexId, rank, distance, tag) => { 154 visited.Add(currentVertexId); 155 return false; 156 }; 157 graph.BreadthFirstWalk(handler, 0, DirectedWalkMode.All, true, null); 158 Assert.AreEqual(4, visited.Count); 159 Assert.IsTrue(visited.Contains(0)); 160 Assert.IsTrue(visited.Contains(1)); 161 Assert.IsTrue(visited.Contains(2)); 162 Assert.IsTrue(visited.Contains(3)); 163 } 164 165 [TestMethod] 166 [TestCategory("ExtLibs")] 167 [TestCategory("ExtLibs.igraph")] 168 [TestProperty("Time", "short")] 169 public void IGraphWrappersGraphDepthFirstWalkTest() { 170 var graph = new Graph(4, new[] { 171 Tuple.Create(0, 1), 172 Tuple.Create(0, 2), 173 Tuple.Create(1, 2), 174 Tuple.Create(2, 0), 175 Tuple.Create(3, 2), 176 }, directed: true); 177 var visited = new HashSet<int>(); 178 DepthFirstHandler handler = (graph1, vertexId, distance, tag) => { 179 visited.Add(vertexId); 180 return false; 181 }; 182 graph.DepthFirstWalk(handler, handler, 0, DirectedWalkMode.All, true, null); 183 Assert.AreEqual(4, visited.Count); 184 Assert.IsTrue(visited.Contains(0)); 185 Assert.IsTrue(visited.Contains(1)); 186 Assert.IsTrue(visited.Contains(2)); 187 Assert.IsTrue(visited.Contains(3)); 188 } 127 189 } 128 190 } -
branches/symbreg-factors-2650/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersMatrixTest.cs
r14276 r14277 27 27 public class IGraphWrappersMatrixTest { 28 28 [TestMethod] 29 public void IGraphWrappersMatrixConstructionAndFinalization() { 29 [TestCategory("ExtLibs")] 30 [TestCategory("ExtLibs.igraph")] 31 [TestProperty("Time", "short")] 32 public void IGraphWrappersMatrixConstructionAndFinalizationTest() { 30 33 var matrix = new Matrix(3, 2); 31 34 Assert.AreEqual(3, matrix.Rows); … … 37 40 Assert.AreEqual(2, other.Columns); 38 41 Assert.AreEqual(4, other[0, 0]); 42 43 var mat = new double[,] { 44 { 1, 2, 3 }, 45 { 4, 5, 6} 46 }; 47 matrix = new Matrix(mat); 48 Assert.AreEqual(2, matrix.Rows); 49 Assert.AreEqual(3, matrix.Columns); 50 var test = matrix.ToMatrix(); 51 for (var i = 0; i < matrix.Rows; i++) 52 for (var j = 0; j < matrix.Columns; j++) { 53 Assert.AreEqual(mat[i, j], matrix[i, j]); 54 Assert.AreEqual(mat[i, j], test[i, j]); 55 } 39 56 } 40 57 41 58 [TestMethod] 59 [TestCategory("ExtLibs")] 60 [TestCategory("ExtLibs.igraph")] 61 [TestProperty("Time", "short")] 42 62 public void IGraphWrappersMatrixGetSetTest() { 43 63 var matrix = new Matrix(3, 2); … … 61 81 Assert.AreEqual(matrix[i, j], netmat[i, j]); 62 82 } 83 84 [TestMethod] 85 [TestCategory("ExtLibs")] 86 [TestCategory("ExtLibs.igraph")] 87 [TestProperty("Time", "short")] 88 public void IGraphWrappersMatrixFillTest() { 89 var matrix = new Matrix(3, 2); 90 matrix.Fill(2.6); 91 Assert.AreEqual(2.6, matrix[0, 0]); 92 Assert.AreEqual(2.6, matrix[0, 1]); 93 Assert.AreEqual(2.6, matrix[1, 0]); 94 Assert.AreEqual(2.6, matrix[1, 1]); 95 Assert.AreEqual(2.6, matrix[2, 0]); 96 Assert.AreEqual(2.6, matrix[2, 1]); 97 } 98 99 [TestMethod] 100 [TestCategory("ExtLibs")] 101 [TestCategory("ExtLibs.igraph")] 102 [TestProperty("Time", "short")] 103 public void IGraphWrappersMatrixTransposeTest() { 104 var matrix = new Matrix(3, 2); 105 matrix.Transpose(); 106 Assert.AreEqual(2, matrix.Rows); 107 Assert.AreEqual(3, matrix.Columns); 108 } 109 110 [TestMethod] 111 [TestCategory("ExtLibs")] 112 [TestCategory("ExtLibs.igraph")] 113 [TestProperty("Time", "short")] 114 public void IGraphWrappersMatrixScaleTest() { 115 var matrix = new Matrix(3, 2); 116 matrix[0, 0] = matrix[0, 1] = 4; 117 matrix[1, 0] = 3; 118 matrix[1, 1] = 2; 119 matrix[2, 0] = 1.5; 120 matrix[2, 1] = -0.5; 121 matrix.Scale(2); 122 Assert.AreEqual(8, matrix[0, 0]); 123 Assert.AreEqual(8, matrix[0, 1]); 124 Assert.AreEqual(6, matrix[1, 0]); 125 Assert.AreEqual(4, matrix[1, 1]); 126 Assert.AreEqual(3, matrix[2, 0]); 127 Assert.AreEqual(-1, matrix[2, 1]); 128 } 63 129 } 64 130 } -
branches/symbreg-factors-2650/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersVectorTest.cs
r14276 r14277 20 20 #endregion 21 21 22 using System.Linq; 22 23 using HeuristicLab.IGraph.Wrappers; 23 24 using Microsoft.VisualStudio.TestTools.UnitTesting; … … 27 28 public class IGraphWrappersVectorTest { 28 29 [TestMethod] 29 public void IGraphWrappersVectorConstructionAndFinalization() { 30 [TestCategory("ExtLibs")] 31 [TestCategory("ExtLibs.igraph")] 32 [TestProperty("Time", "short")] 33 public void IGraphWrappersVectorConstructionAndFinalizationTest() { 30 34 var vector = new Vector(7); 31 35 Assert.AreEqual(7, vector.Length); … … 35 39 Assert.AreEqual(7, other.Length); 36 40 Assert.AreEqual(4, other[0]); 41 42 var myvec = new double[] { 1, 2, 3 }; 43 vector = new Vector(myvec); 44 Assert.AreEqual(3, vector.Length); 45 Assert.AreEqual(myvec[0], vector[0]); 46 Assert.AreEqual(myvec[1], vector[1]); 47 Assert.AreEqual(myvec[2], vector[2]); 37 48 } 38 49 39 50 [TestMethod] 51 [TestCategory("ExtLibs")] 52 [TestCategory("ExtLibs.igraph")] 53 [TestProperty("Time", "short")] 40 54 public void IGraphWrappersVectorGetSetTest() { 41 55 var vector = new Vector(5); … … 55 69 Assert.AreEqual(vector[i], netmat[i]); 56 70 } 71 72 [TestMethod] 73 [TestCategory("ExtLibs")] 74 [TestCategory("ExtLibs.igraph")] 75 [TestProperty("Time", "short")] 76 public void IGraphWrappersVectorFillTest() { 77 var vector = new Vector(5); 78 vector.Fill(2.3); 79 Assert.IsTrue(new[] { 2.3, 2.3, 2.3, 2.3, 2.3 }.SequenceEqual(vector.ToArray())); 80 } 81 82 [TestMethod] 83 [TestCategory("ExtLibs")] 84 [TestCategory("ExtLibs.igraph")] 85 [TestProperty("Time", "short")] 86 public void IGraphWrappersVectorReverseTest() { 87 var vector = new Vector(5); 88 vector[0] = vector[1] = 4; 89 vector[2] = 3; 90 vector[3] = 1.5; 91 vector[4] = -0.5; 92 vector.Reverse(); 93 Assert.IsTrue(new[] { -0.5, 1.5, 3, 4, 4 }.SequenceEqual(vector.ToArray())); 94 } 95 96 [TestMethod] 97 [TestCategory("ExtLibs")] 98 [TestCategory("ExtLibs.igraph")] 99 [TestProperty("Time", "short")] 100 public void IGraphWrappersVectorShuffleTest() { 101 var vector = new Vector(5); 102 vector[0] = vector[1] = 4; 103 vector[2] = 3; 104 vector[3] = 1.5; 105 vector[4] = -0.5; 106 vector.Shuffle(); 107 Assert.IsFalse(new[] { -0.5, 1.5, 3, 4, 4 }.SequenceEqual(vector.ToArray())); 108 Assert.IsFalse(new[] { 4, 4, 3, 1.5, -0.5 }.SequenceEqual(vector.ToArray())); 109 } 110 111 [TestMethod] 112 [TestCategory("ExtLibs")] 113 [TestCategory("ExtLibs.igraph")] 114 [TestProperty("Time", "short")] 115 public void IGraphWrappersVectorScaleTest() { 116 var vector = new Vector(5); 117 vector[0] = vector[1] = 4; 118 vector[2] = 3; 119 vector[3] = 1.5; 120 vector[4] = -0.5; 121 vector.Scale(2); 122 Assert.IsTrue(new double[] { 8, 8, 6, 3, -1 }.SequenceEqual(vector.ToArray())); 123 } 57 124 } 58 125 }
Note: See TracChangeset
for help on using the changeset viewer.