没啥大用,主要是想写练练手,而且还没写完
class ForwardStar{
private:
struct edge{
char id;
int next;
int to;
int weight;
};
vector<edge> e;
vector<int> first;
public:
void clear(){
e.clear();
first.clear();
edge Lr;
e.push_back(Lr);
first.push_back(0);
}
void Point_resize(int size){
first.resize(size+1);
}
void clear(int size){
clear();
Point_resize(size);
}
void Add_edge(int start,int end){
edge Lr;
Lr.next=first[start];
Lr.to=end;
Lr.weight=0;
Lr.id='0';
e.push_back(Lr);
first[start]=e.size()-1;
}
void Add_edge(int start,int end,int weight){
edge Lr;
Lr.next=first[start];
Lr.to=end;
Lr.weight=weight;
Lr.id='0';
e.push_back(Lr);
first[start]=e.size()-1;
}
void Add_edge(int start,int end,int weight,char id){
edge Lr;
Lr.next=first[start];
Lr.to=end;
Lr.weight=weight;
Lr.id=id;
e.push_back(Lr);
first[start]=e.size()-1;
}
void PartPrint_edgeid(int start){
for(int i=first[start];i!=0;i=e[i].next){
cout<<e[i].id<<endl;
}
}
void Print_edgeid(){
for(int i=first.size()-1;i>=1;--i){
PartPrint_edgeid(i);
}
}
void PartPrint_edge(int start){
for(int i=first[start];i!=0;i=e[i].next){
cout<<i<<" : from "<<start<<" to "<<e[i].to<<" with the weight of "<<e[i].weight<<endl;
}
}
void Print_edge(){
for(int i=first.size()-1;i>=1;--i){
PartPrint_edge(i);
}
}
void Print(int id){
cout<<id<<" : "<<"to "<<e[id].to<<" with the weight of "<<e[id].weight<<endl;
}
int Find(int start,int end){
for(int i=first[start];i!=0;i=e[i].next){
if(e[i].to==end){
return i;
}
}
return -1;
}
void Find_Print(int start,int end){
int x=Find(start,end);
if(x>0){
Print(x);
}
else{
cout<<"Not Found."<<endl;
}
}
void Sec_EulerianPath(){
}
void Sec_EulerianCircuit(){
}
void Sec_DFS(){
}
void Sec_BFS(){
}
void Srt_Floyed(){
}
void Srt_Dijkstra(){
}
void Srt_BellmanFold(){
}
void Srt_SPFA(){
}
};