Beispiel #1
0
int main(){
   graphADT graph = GraphCreate() ;
   GraphAddVertex(graph, 'A') ;
   GraphAddVertex(graph, 'B') ;
   GraphAddVertex(graph, 'C') ;
   GraphAddVertex(graph, 'D') ;
   GraphAddVertex(graph, 'E') ;
   
   GraphAddEdge( getVertex(graph, 'A'), getVertex(graph, 'C') ) ;
   GraphAddEdge( getVertex(graph, 'C'), getVertex(graph, 'D') ) ;
   GraphAddEdge( getVertex(graph, 'D'), getVertex(graph, 'E') ) ;
   GraphAddEdge( getVertex(graph, 'B'), getVertex(graph, 'E') ) ;

   printf("\n Is vertex E reachable from A? : %s \n ",   isDestReachable(graph, 'A', 'E')==true?"True":"False" ) ;
   printf("\n Is vertex E reachable from B? : %s\n ",    isDestReachable(graph, 'B', 'E')==true?"True":"False" ) ;
   printf("\n Is vertex D reachable from A? : %s \n ",   isDestReachable(graph, 'A', 'D')==true?"True":"False" ) ;
   printf("\n Is vertex E reachable from D? : %s \n ",   isDestReachable(graph, 'D', 'E')==true?"True":"False" ) ;
   printf("\n Is vertex B reachable from A? : %s \n ",   isDestReachable(graph, 'A', 'B')==true?"True":"False" ) ;
   printf("\n Is vertex D reachable from C? : %s \n ",   isDestReachable(graph, 'C', 'D')==true?"True":"False" ) ;
   return 0;
}
Beispiel #2
0
int main(){

 struct vertex* head = NULL;

 GraphAddVertex(&head,6);
 GraphAddVertex(&head,5);
 GraphAddVertex(&head,4);
 GraphAddVertex(&head,3);
 GraphAddVertex(&head,2);
 GraphAddVertex(&head,1);
 printVertex(head);

 GraphAddEdge(head,1,2,1);
 struct edge* ed = head->edges;

 printf("%d\n",ed==NULL); 
 printEdge(head);
return 0;
}