Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/08/16 11:41:45 (8 years ago)
Author:
gkronber
Message:

#2650: merged r14245:14273 from trunk to branch (fixing conflicts in RegressionSolutionTargetResponseGradientView)

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  
    2929  public class IGraphLayoutTest {
    3030    [TestMethod]
    31     public void TestFruchtermanReingold() {
     31    [TestCategory("ExtLibs")]
     32    [TestCategory("ExtLibs.igraph")]
     33    [TestProperty("Time", "short")]
     34    public void IGraphWrappersLayoutFruchtermanReingoldTest() {
    3235      var graph = new Graph(5, new[] {
    3336        Tuple.Create(0, 1),
  • branches/symbreg-factors-2650/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersGraphTest.cs

    r14276 r14277  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.IGraph.Wrappers;
     
    2728namespace HeuristicLab.Tests {
    2829  [TestClass]
     30  [DeploymentItem("igraph-0.8.0-pre-x86.dll")]
     31  [DeploymentItem("igraph-0.8.0-pre-x64.dll")]
    2932  public class IGraphWrappersGraphTest {
    3033    [TestMethod]
    31     public void IGraphWrappersGraphConstructionAndFinalization() {
     34    [TestCategory("ExtLibs")]
     35    [TestCategory("ExtLibs.igraph")]
     36    [TestProperty("Time", "short")]
     37    public void IGraphWrappersGraphConstructionAndFinalizationTest() {
    3238      var graph = new Graph(5, new[] {
    3339        Tuple.Create(0, 1),
     
    5157
    5258    [TestMethod]
    53     public void TestDensity() {
     59    [TestCategory("ExtLibs")]
     60    [TestCategory("ExtLibs.igraph")]
     61    [TestProperty("Time", "short")]
     62    public void IGraphWrappersGraphDensityTest() {
    5463      var graph = new Graph(5, new[] {
    5564        Tuple.Create(0, 1),
     
    8291
    8392    [TestMethod]
    84     public void TestPageRank() {
     93    [TestCategory("ExtLibs")]
     94    [TestCategory("ExtLibs.igraph")]
     95    [TestProperty("Time", "short")]
     96    public void IGraphWrappersGraphPageRankTest() {
    8597      var graph = new Graph(4, new[] {
    8698        Tuple.Create(0, 1),
     
    125137      Assert.AreEqual(0.173, ranks[3], 0.01);
    126138    }
     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    }
    127189  }
    128190}
  • branches/symbreg-factors-2650/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersMatrixTest.cs

    r14276 r14277  
    2727  public class IGraphWrappersMatrixTest {
    2828    [TestMethod]
    29     public void IGraphWrappersMatrixConstructionAndFinalization() {
     29    [TestCategory("ExtLibs")]
     30    [TestCategory("ExtLibs.igraph")]
     31    [TestProperty("Time", "short")]
     32    public void IGraphWrappersMatrixConstructionAndFinalizationTest() {
    3033      var matrix = new Matrix(3, 2);
    3134      Assert.AreEqual(3, matrix.Rows);
     
    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("ExtLibs.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("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    }
    63129  }
    64130}
  • branches/symbreg-factors-2650/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersVectorTest.cs

    r14276 r14277  
    2020#endregion
    2121
     22using System.Linq;
    2223using HeuristicLab.IGraph.Wrappers;
    2324using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    2728  public class IGraphWrappersVectorTest {
    2829    [TestMethod]
    29     public void IGraphWrappersVectorConstructionAndFinalization() {
     30    [TestCategory("ExtLibs")]
     31    [TestCategory("ExtLibs.igraph")]
     32    [TestProperty("Time", "short")]
     33    public void IGraphWrappersVectorConstructionAndFinalizationTest() {
    3034      var vector = new Vector(7);
    3135      Assert.AreEqual(7, vector.Length);
     
    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("ExtLibs.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("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    }
    57124  }
    58125}
Note: See TracChangeset for help on using the changeset viewer.