Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/08/16 23:36:49 (8 years ago)
Author:
abeham
Message:

#2651: worked on igraph integration

Location:
trunk/sources/HeuristicLab.Tests/HeuristicLab.IGraph
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphLayoutTest.cs

    r14244 r14245  
    2929  public class IGraphLayoutTest {
    3030    [TestMethod]
    31     public void TestFruchtermanReingold() {
     31    [TestCategory("ExtLibs")]
     32    [TestCategory("igraph")]
     33    [TestProperty("Time", "short")]
     34    public void FruchtermanReingoldLayoutTest() {
    3235      var graph = new Graph(5, new[] {
    3336        Tuple.Create(0, 1),
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersGraphTest.cs

    r14244 r14245  
    2929  public class IGraphWrappersGraphTest {
    3030    [TestMethod]
     31    [TestCategory("ExtLibs")]
     32    [TestCategory("igraph")]
     33    [TestProperty("Time", "short")]
    3134    public void IGraphWrappersGraphConstructionAndFinalization() {
    3235      var graph = new Graph(5, new[] {
     
    5154
    5255    [TestMethod]
     56    [TestCategory("ExtLibs")]
     57    [TestCategory("igraph")]
     58    [TestProperty("Time", "short")]
    5359    public void TestDensity() {
    5460      var graph = new Graph(5, new[] {
     
    8288
    8389    [TestMethod]
     90    [TestCategory("ExtLibs")]
     91    [TestCategory("igraph")]
     92    [TestProperty("Time", "short")]
    8493    public void TestPageRank() {
    8594      var graph = new Graph(4, new[] {
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersMatrixTest.cs

    r14244 r14245  
    2727  public class IGraphWrappersMatrixTest {
    2828    [TestMethod]
     29    [TestCategory("ExtLibs")]
     30    [TestCategory("igraph")]
     31    [TestProperty("Time", "short")]
    2932    public void IGraphWrappersMatrixConstructionAndFinalization() {
    3033      var matrix = new Matrix(3, 2);
     
    3740      Assert.AreEqual(2, other.Columns);
    3841      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        }
    3956    }
    4057
    4158    [TestMethod]
     59    [TestCategory("ExtLibs")]
     60    [TestCategory("igraph")]
     61    [TestProperty("Time", "short")]
    4262    public void IGraphWrappersMatrixGetSetTest() {
    4363      var matrix = new Matrix(3, 2);
     
    6181          Assert.AreEqual(matrix[i, j], netmat[i, j]);
    6282    }
     83
     84    [TestMethod]
     85    [TestCategory("ExtLibs")]
     86    [TestCategory("igraph")]
     87    [TestProperty("Time", "short")]
     88    public void IGraphWrappersMatrixFill() {
     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("igraph")]
     102    [TestProperty("Time", "short")]
     103    public void IGraphWrappersMatrixTranspose() {
     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("igraph")]
     113    [TestProperty("Time", "short")]
     114    public void IGraphWrappersMatrixScale() {
     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    }
    63129  }
    64130}
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersVectorTest.cs

    r14244 r14245  
    2020#endregion
    2121
     22using System.Linq;
    2223using HeuristicLab.IGraph.Wrappers;
    2324using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    2728  public class IGraphWrappersVectorTest {
    2829    [TestMethod]
     30    [TestCategory("ExtLibs")]
     31    [TestCategory("igraph")]
     32    [TestProperty("Time", "short")]
    2933    public void IGraphWrappersVectorConstructionAndFinalization() {
    3034      var vector = new Vector(7);
     
    3539      Assert.AreEqual(7, other.Length);
    3640      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]);
    3748    }
    3849
    3950    [TestMethod]
     51    [TestCategory("ExtLibs")]
     52    [TestCategory("igraph")]
     53    [TestProperty("Time", "short")]
    4054    public void IGraphWrappersVectorGetSetTest() {
    4155      var vector = new Vector(5);
     
    5569        Assert.AreEqual(vector[i], netmat[i]);
    5670    }
     71
     72    [TestMethod]
     73    [TestCategory("ExtLibs")]
     74    [TestCategory("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("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("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("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    }
    57124  }
    58125}
Note: See TracChangeset for help on using the changeset viewer.