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

📄 node.h

📁 无线传感器网络leach协议无线传感器网络leach协议无线传感器网络leach协议
💻 H
字号:
#pragma once

#include <math.h>

class NodeSort;
class Leach;

class Node
{
private:
    double px;
    double py;
    int id;     //节点编号
    double ne;
    

    NodeSort * DistanceList;// 保存排序过的距离

    unsigned int NodeCount;//节点总数

public:

    bool IsCluster; //是否成为过簇头
    bool IsCurrentCluster; //是否为当前的簇头

    Node();
    Node(unsigned int Count, int mid);
    ~Node(void);

    int OnBecomeCluster(void);
    int OnNoneCluster(void);
    void SetDistance(Node * DstList);
	double GetE();
	void SetE(double e);
	int consumeE(Node &a ,Node &b);
    //Count 是节点总数,每个节点都保存一个节点总数的信息。
    //id 是节点编号
    void SetNode(unsigned int Count, int id);
    
    friend class NodeSort;
    friend class Leach;
    
};

class NodeSort
{
private:
    double Distance;
    Node * DstNode;
public:

    static int Compare(NodeSort * s1, NodeSort * s2)
    {
        return (int)(s1->Distance - s2->Distance);
    }

    void ComputeDistance(Node * node1, Node * node2)
    {
        Distance = sqrt( pow(node1->px - node2->px, 2) + pow(node1->py - node2->py, 2));
        DstNode = node2;
    }
    friend class Node;

};

⌨️ 快捷键说明

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