Skip to content
Permalink
7c0b972a95
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
27 lines (26 sloc) 662 Bytes
class Graph{
ArrayList<Vertex> V=new ArrayList();
ArrayList<Edge> E=new ArrayList();
boolean ValidNewEdge(Vertex v1,Vertex v2){
if(v1==v2)return false;
for(Edge i:v1.E){
if((i.v1==v1)&&(i.v2==v2))return false;
if((i.v2==v1)&&(i.v1==v2))return false;
}
return true;
}
boolean ValidGraph(){
int min=Integer.MAX_VALUE;
for(Vertex i:V){
if(i.E.size()<=min)min=i.E.size();
}
boolean x= (min==3);
boolean y= E.size() <= (3*V.size() -6);
return x&&y;
}
boolean check3edges_per_vertex(Vertex v){
if(v.E.size()<3) return true;
if(v.E.size()>=3) return false;
return true;
}
}