⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qydirectedpath.h

📁 kth算法的实现
💻 H
字号:
// ____________________________________________________________________________////  General Information:////  File Name:      QYDirectedPath.h//  Author:         Yan Qi//  Project:        KShortestPath////  Description:    Declaration of class(es) CQYDirectedPath////  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//  Revision History:////  11/21/2006   Yan   Initial Version////  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//  Copyright Notice:////  Copyright (c) 2006 Your Company Inc.////  Warning: This computer program is protected by copyright law and //  international treaties.  Unauthorized reproduction or distribution//  of this program, or any portion of it, may result in severe civil and//  criminal penalties, and will be prosecuted to the maximum extent //  possible under the law.//// ____________________________________________________________________________#ifndef _QYDIRECTEDPATH_H_#define _QYDIRECTEDPATH_H_#include <iterator>#include <vector>#include <fstream>#include <algorithm>namespace asu_emit_qyan{		class CQYDirectedPath  	{	public:		class Comparator 		{		public:			//the comparison			bool operator() (const CQYDirectedPath& s1, const CQYDirectedPath& s2) const 			{				if (s1.GetCost() == s2.GetCost())				{					return s1.GetLength() < s2.GetLength();				}				return s1.GetCost() < s2.GetCost();			}			//			bool operator() (const CQYDirectedPath* s1, const CQYDirectedPath* s2) const 			{				return operator()(*s1, *s2);			}		}; 			public:		CQYDirectedPath(){};		CQYDirectedPath(int pId, double pCost, const std::vector<int>& pVertexList)			:m_nId(pId), m_dCost(pCost)		{m_vVertexList.assign(pVertexList.begin(), pVertexList.end());}				virtual ~CQYDirectedPath(){};				// Getter and Setter		int GetId() const { return m_nId; }		void SetId(int val) { m_nId = val; }				double GetCost() const { return m_dCost; }		void SetCost(double val) { m_dCost = val; }				int GetLength() const { return m_vVertexList.size(); }				std::vector<int> GetVertexList() const { return m_vVertexList; }		void SetVertexList(std::vector<int> val) { m_vVertexList = val; }				int GetSourceNodeId() const { return m_nSourceNodeId; }		void SetSourceNodeId(int val) { m_nSourceNodeId = val; }				int GetTerminalNodeId() const { return m_nTerminalNodeId; }		void SetTerminalNodeId(int val) { m_nTerminalNodeId = val; }				////		void PrintOut(std::ostream& out_stream)		{			out_stream << "Cost: " << m_dCost 				<< " Length: " << m_vVertexList.size()				<< std::endl;			std::copy(m_vVertexList.rbegin(), m_vVertexList.rend(), std::ostream_iterator<int>(out_stream, " "));			out_stream << std::endl <<  "*********************************************" << std::endl;			}		void GetPath(std::vector<int> &path)		{			path.resize(m_vVertexList.size());			std::copy(m_vVertexList.rbegin(), m_vVertexList.rend(), path.begin());		}	private: // members		int m_nId;		int m_nLength;		double m_dCost;  		std::vector<int> m_vVertexList; // record the nodes through the path				int m_nSourceNodeId;		int m_nTerminalNodeId;	};}#endif //_QYDIRECTEDPATH_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -