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

📄 graph.cpp

📁 对图进行匹配的算法
💻 CPP
字号:
// graph.cpp: implementation of the graph class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "graph.h"

#ifndef NULL
#define NULL 0
#endif 
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

graph::graph()
{
head=&midhead;
len=0;
head->next=NULL;
cur=head;
next=head;
}

graph::~graph()
{

}

void graph::addnode(node *nd)
{
cur->next=nd;
len++;
cur=nd;
}

node * graph::delnode(node *nd)
{
node *temp;
temp=head;
while(temp->next!=nd&&temp->next!=NULL)
   temp=temp->next;
if(temp->next==NULL)
return NULL;
else
{
if(temp->next->next==NULL)
cur=temp;
temp->next=temp->next->next;
len--;
return nd;
}
}

bool graph::find(node *nd)
{
node *temp;
temp=head;
while(temp->next!=nd&&temp->next!=NULL)
   temp=temp->next;
if(temp->next==NULL)
  return 0;
else
  return 1;
}

int graph::getlength()
{
return len;
}

node * graph::getnext()
{
if(next!=NULL)
{
 next=next->next;
 return next;
}
else
return NULL;
}

void graph::reset()
{
next=head;
}

node * graph::delnode(int num)
{
node *temp,*res;
temp=head;
while(temp->next->number!=num&&temp->next!=NULL)
   temp=temp->next;
if(temp->next==NULL)
return NULL;
else
{
if(temp->next->next==NULL)
cur=temp;
res=temp->next;
temp->next=temp->next->next;
len--;
return res;
}
}

⌨️ 快捷键说明

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