Пример #1
0
        public void ConversionTest()
        {
            var e1 = new EdgeId(0, 1);

            e1.Value.Should().Be(1);

            var e2 = new EdgeId(1, 0);

            e2.Value.Should().Be(4294967296);

            var e3 = new EdgeId(1, 1);

            e3.Value.Should().Be(4294967297);

            var e4 = new EdgeId(2, 2);
            var e5 = new EdgeId(2, 2);

            (e1 == e2).Should().BeFalse();
            (e1 != e2).Should().BeTrue();

            (e1 == e3).Should().BeFalse();
            (e4 == e5).Should().BeTrue();
            (e1 != e3).Should().BeTrue();
            (e4 != e5).Should().BeFalse();

            (e1 < e2).Should().BeTrue();
            (e1 > e2).Should().BeFalse();
            (e4 > e3).Should().BeTrue();

            e1.CompareTo(e2).Should().Be(-1);
            e2.CompareTo(e1).Should().Be(1);
            e4.CompareTo(e5).Should().Be(0);
        }
Пример #2
0
    public IEnumerator Run()
    {
        while (queue.Count != 0)
        {
            int u = MinVertex();
            Debug.Log(u);
            queue.Remove(u);
            // starting to consider a vertex
            yield return(System.Tuple.Create(u, false));

            int e_idx = 0;
            //bool best_so_far = false;
            foreach (Edge e in graph[u])
            {
                // I'm considering an edge...
                yield return(new EdgeId(u, e_idx));

                int    alt      = dist[u] + e.d;
                EdgeId old_prev = prev[e.v];
                if (alt < dist[e.v])
                {
                    dist[e.v] = alt;
                    prev[e.v] = new EdgeId(u, e_idx);
                    //best_so_far = true;
                }
                e_idx++;
                // The best edge to e.v after considering this edge
                yield return(System.Tuple.Create(prev[e.v], old_prev));
            }
            // finished with vertex u
            yield return(System.Tuple.Create(u, true));
        }
        yield return(-1);
    }
Пример #3
0
 public void EdgeIdEmptyConstructorTest()
 {
     var _EdgeId1 = new EdgeId();
     var _EdgeId2 = new EdgeId();
     Assert.IsTrue(_EdgeId1.Length > 0);
     Assert.IsTrue(_EdgeId2.Length > 0);
     Assert.AreNotEqual(_EdgeId1, _EdgeId2);
 }
Пример #4
0
 public HaymanEdge(IHaymanVertex outVertex,
                   IHaymanVertex inVertex,
                   EdgeId id)
 {
     _outVertex = outVertex;
     _inVertex = inVertex;
     _id = id;
 }
Пример #5
0
 public override bool Equals(object obj)
 {
     if (obj == null || GetType() != obj.GetType())
     {
         return(false);
     }
     return(EdgeId.Equals((Edge)obj));
 }
Пример #6
0
        /// <summary>
        /// Add an edge to the graph. The added edges requires a recommended identifier, a tail vertex, an head vertex, and a label.
        /// Like adding a vertex, the provided object identifier is can be ignored by the implementation.
        /// </summary>
        /// <param name="outVertex">The vertex on the tail of the edge.</param>
        /// <param name="inVertex">The vertex on the head of the edge.</param>
        /// <param name="id">The recommended object identifier.</param>
        /// <param name="label">The label associated with the edge.</param>
        /// <param name="edgeInitializer">A delegate to initialize the new edge.</param>
        /// <returns>
        /// The newly created edge
        /// </returns>
        public IHaymanEdge AddEdge(IHaymanVertex outVertex, IHaymanVertex inVertex, EdgeId id, string label, Action<HaymanEdgeData> edgeInitializer)
        {
            var data = new HaymanEdgeData();

            if (edgeInitializer != null)
            {

                edgeInitializer(data);
            }

            var edge = new HaymanEdge(outVertex, inVertex, id) { EdgeData = data };
            outVertex.AddInEdge(edge);
            inVertex.AddOutEdge(edge);
            _edges.Add(id, edge);
            return edge;
        }
Пример #7
0
        public void EdgeId_New_Works_For(ulong value)
        {
            var id = new EdgeId(value);

            Assert.That(id.Value, Is.EqualTo(value));
        }
Пример #8
0
 public void op_BiggerOrEqual_Null_Test2()
 {
     EdgeId _EdgeId1 = null;
     var      _EdgeId2 = new EdgeId();
     Assert.IsTrue(_EdgeId1 >= _EdgeId2);
 }
Пример #9
0
 public void op_Bigger_Smaller2_Test()
 {
     var _EdgeId1 = new EdgeId(5);
     var _EdgeId2 = new EdgeId(23);
     Assert.IsFalse(_EdgeId1 > _EdgeId2);
 }
Пример #10
0
 public void op_Bigger_Equals_Test()
 {
     var _EdgeId1 = new EdgeId(1);
     var _EdgeId2 = new EdgeId(1);
     Assert.IsFalse(_EdgeId1 > _EdgeId2);
 }
Пример #11
0
 public void op_Bigger_Null_Test1()
 {
     var      _EdgeId1 = new EdgeId();
     EdgeId _EdgeId2 = null;
     Assert.IsTrue(_EdgeId1 > _EdgeId2);
 }
Пример #12
0
 public void op_SmallerOrEqual_SmallerThan2_Test()
 {
     var _EdgeId1 = new EdgeId(5);
     var _EdgeId2 = new EdgeId(23);
     Assert.IsTrue(_EdgeId1 <= _EdgeId2);
 }
Пример #13
0
 public void op_SmallerOrEqual_Equals_Test()
 {
     var _EdgeId1 = new EdgeId(1);
     var _EdgeId2 = new EdgeId(1);
     Assert.IsTrue(_EdgeId1 <= _EdgeId2);
 }
Пример #14
0
 public void op_Equality_NotEquals_Test()
 {
     var _EdgeId1 = new EdgeId(1);
     var _EdgeId2 = new EdgeId(2);
     Assert.IsFalse(_EdgeId1 == _EdgeId2);
 }
Пример #15
0
 public void op_Equality_Null_Test2()
 {
     EdgeId _EdgeId1 = null;
     var    _EdgeId2 = new EdgeId();
     Assert.IsFalse(_EdgeId1 == _EdgeId2);
 }
Пример #16
0
 public void EdgeIdUriConstructorTest()
 {
     var _EdgeId = new EdgeId(new Uri("http://example.org"));
     Assert.AreEqual("http://example.org/", _EdgeId.ToString());
     Assert.AreEqual(19,                    _EdgeId.Length);
 }
Пример #17
0
 public override int GetHashCode()
 {
     return(EdgeId.GetHashCode() + TimeTableId.GetHashCode());
 }
Пример #18
0
 public void op_Inequality_Null_Test2()
 {
     EdgeId _EdgeId1 = null;
     var      _EdgeId2 = new EdgeId();
     Assert.IsTrue(_EdgeId1 != _EdgeId2);
 }
Пример #19
0
 public void op_SmallerOrEqual_Null_Test1()
 {
     var      _EdgeId1 = new EdgeId();
     EdgeId _EdgeId2 = null;
     Assert.IsTrue(_EdgeId1 <= _EdgeId2);
 }
Пример #20
0
 public void op_Inequality_SameReference_Test()
 {
     var _EdgeId1 = new EdgeId();
     #pragma warning disable
     Assert.IsFalse(_EdgeId1 != _EdgeId1);
     #pragma warning restore
 }
Пример #21
0
 public void EdgeIdStringConstructorTest()
 {
     var _EdgeId = new EdgeId("123");
     Assert.AreEqual("123", _EdgeId.ToString());
     Assert.AreEqual(3,     _EdgeId.Length);
 }
Пример #22
0
 public void op_Inequality_Equals_Test()
 {
     var _EdgeId1 = new EdgeId(1);
     var _EdgeId2 = new EdgeId(1);
     Assert.IsFalse(_EdgeId1 != _EdgeId2);
 }
Пример #23
0
 public void op_SmallerOrEqual_Bigger1_Test()
 {
     var _EdgeId1 = new EdgeId(2);
     var _EdgeId2 = new EdgeId(1);
     Assert.IsFalse(_EdgeId1 <= _EdgeId2);
 }
Пример #24
0
 public void op_Inequality_NotEquals2_Test()
 {
     var _EdgeId1 = new EdgeId(5);
     var _EdgeId2 = new EdgeId(23);
     Assert.IsTrue(_EdgeId1 != _EdgeId2);
 }
Пример #25
0
 public void op_Bigger_SameReference_Test()
 {
     var _EdgeId1 = new EdgeId();
     #pragma warning disable
     Assert.IsFalse(_EdgeId1 > _EdgeId1);
     #pragma warning restore
 }
Пример #26
0
 public void op_Smaller_Null_Test2()
 {
     EdgeId _EdgeId1 = null;
     var      _EdgeId2 = new EdgeId();
     Assert.IsTrue(_EdgeId1 < _EdgeId2);
 }
Пример #27
0
 public void EdgeIdInt32ConstructorTest()
 {
     var _EdgeId = new EdgeId(5);
     Assert.AreEqual("5", _EdgeId.ToString());
     Assert.AreEqual(1,   _EdgeId.Length);
 }
Пример #28
0
 public void EdgeIdUInt32ConstructorTest()
 {
     var _EdgeId = new EdgeId(23U);
     Assert.AreEqual("23", _EdgeId.ToString());
     Assert.AreEqual(2,    _EdgeId.Length);
 }
Пример #29
0
 public void op_Bigger_Bigger1_Test()
 {
     var _EdgeId1 = new EdgeId(2);
     var _EdgeId2 = new EdgeId(1);
     Assert.IsTrue(_EdgeId1 > _EdgeId2);
 }
Пример #30
0
 public void op_BiggerOrEqual_Bigger2_Test()
 {
     var _EdgeId1 = new EdgeId(23);
     var _EdgeId2 = new EdgeId(5);
     Assert.IsTrue(_EdgeId1 >= _EdgeId2);
 }
Пример #31
0
 public void op_BiggerOrEqual_SameReference_Test()
 {
     var _EdgeId1 = new EdgeId();
     #pragma warning disable
     Assert.IsTrue(_EdgeId1 >= _EdgeId1);
     #pragma warning restore
 }
Пример #32
0
        public void EdgeId_New_Works()
        {
            var id = new EdgeId();

            Assert.That(id.Value, Is.Not.EqualTo(0));
        }
Пример #33
0
 public void op_BiggerOrEqual_SmallerThan2_Test()
 {
     var _EdgeId1 = new EdgeId(5);
     var _EdgeId2 = new EdgeId(23);
     Assert.IsFalse(_EdgeId1 >= _EdgeId2);
 }
Пример #34
0
 public void op_Smaller_Equals_Test()
 {
     var _EdgeId1 = new EdgeId(1);
     var _EdgeId2 = new EdgeId(1);
     Assert.IsFalse(_EdgeId1 < _EdgeId2);
 }
Пример #35
0
 public void CompareToSmallerTest1()
 {
     var _EdgeId1 = new EdgeId(1);
     var _EdgeId2 = new EdgeId(2);
     Assert.IsTrue(_EdgeId1.CompareTo(_EdgeId2) < 0);
 }
Пример #36
0
 public void op_Smaller_Smaller2_Test()
 {
     var _EdgeId1 = new EdgeId(5);
     var _EdgeId2 = new EdgeId(23);
     Assert.IsTrue(_EdgeId1 < _EdgeId2);
 }