Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ParameterBinding/HeuristicLab.ExtLibs/HeuristicLab.LibSVM/1.6.3/LibSVM-1.6.3/Node.cs @ 12051

Last change on this file since 12051 was 2645, checked in by mkommend, 15 years ago

extracted external libraries and adapted dependent plugins (ticket #837)

File size: 2.8 KB
Line 
1/*
2 * SVM.NET Library
3 * Copyright (C) 2008 Matthew Johnson
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19
20using System;
21
22namespace SVM
23{
24    /// <summary>
25    /// Encapsulates a node in a Problem vector, with an index and a value (for more efficient representation
26    /// of sparse data.
27    /// </summary>
28  [Serializable]
29  public class Node : IComparable<Node>
30  {
31        internal int _index;
32        internal double _value;
33
34        /// <summary>
35        /// Default Constructor.
36        /// </summary>
37        public Node()
38        {
39        }
40        /// <summary>
41        /// Constructor.
42        /// </summary>
43        /// <param name="index">The index of the value.</param>
44        /// <param name="value">The value to store.</param>
45        public Node(int index, double value)
46        {
47            _index = index;
48            _value = value;
49        }
50
51        /// <summary>
52        /// Index of this Node.
53        /// </summary>
54        public int Index
55        {
56            get
57            {
58                return _index;
59            }
60            set
61            {
62                _index = value;
63            }
64        }
65        /// <summary>
66        /// Value at Index.
67        /// </summary>
68        public double Value
69        {
70            get
71            {
72                return _value;
73            }
74            set
75            {
76                _value = value;
77            }
78        }
79
80        /// <summary>
81        /// String representation of this Node as {index}:{value}.
82        /// </summary>
83        /// <returns>{index}:{value}</returns>
84        public override string ToString()
85        {
86            return string.Format("{0}:{1}", _index, _value);
87        }
88
89        #region IComparable<Node> Members
90
91        /// <summary>
92        /// Compares this node with another.
93        /// </summary>
94        /// <param name="other">The node to compare to</param>
95        /// <returns>A positive number if this node is greater, a negative number if it is less than, or 0 if equal</returns>
96        public int CompareTo(Node other)
97        {
98            return _index.CompareTo(other._index);
99        }
100
101        #endregion
102    }
103}
Note: See TracBrowser for help on using the repository browser.