/* * SVM.NET Library * Copyright (C) 2008 Matthew Johnson * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ using System; namespace SVM { /// /// Encapsulates a node in a Problem vector, with an index and a value (for more efficient representation /// of sparse data. /// [Serializable] public class Node : IComparable { internal int _index; internal double _value; /// /// Default Constructor. /// public Node() { } /// /// Constructor. /// /// The index of the value. /// The value to store. public Node(int index, double value) { _index = index; _value = value; } /// /// Index of this Node. /// public int Index { get { return _index; } set { _index = value; } } /// /// Value at Index. /// public double Value { get { return _value; } set { _value = value; } } /// /// String representation of this Node as {index}:{value}. /// /// {index}:{value} public override string ToString() { return string.Format("{0}:{1}", _index, _value); } #region IComparable Members /// /// Compares this node with another. /// /// The node to compare to /// A positive number if this node is greater, a negative number if it is less than, or 0 if equal public int CompareTo(Node other) { return _index.CompareTo(other._index); } #endregion } }