Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <time.h>
- #include <stdlib.h>
- #include <sys/time.h>
- #define SIZEMAX 100
- int grafo[SIZEMAX+1][SIZEMAX+1];int it=0;
- int estrella(int n){
- int u,v;int salida;
- for (u=1;u<=n;u++){
- for(v=1;v<=n;v++){
- if (grafo[u][v]==1) {
- salida==1;
- }else{
- salida==0;
- }
- it++;
- }
- if (salida==1) return 1;
- }
- return 0;
- }
- int main(int argc, char** argv) {
- int n,u,v,x,y;
- clock_t start = clock();
- //struct timeval start,end;
- scanf("%d",&n);
- while(1){
- scanf("%d",&x);
- scanf("%d",&y);
- if(x<0 || y<0) break;
- grafo[x][y]=1;
- grafo[y][x]=1;
- }
- //gettimeofday(&start,NULL);
- int topol=estrella(n);
- //gettimeofday(&end,NULL);
- //printf("%ld\n",((end.tv_sec*100000 + end.tv_usec)-(start.tv_sec*1000000 + start.tv_usec)));
- printf("Tiempo transcurrido: %f \n", ((double)clock() - start) / CLOCKS_PER_SEC);
- /*
- for (u=1;u<=n;u++){
- for(v=1;v<=n;v++) printf("%4d",grafo[u][v]);
- printf("\n");
- }
- */
- if (topol){
- printf ("Es topologia estrella \n");
- printf ("El numero de iteraciones fue %d \n",it);
- printf("El numero de vertices del grafo es : %d",n);
- }else{
- printf("No es topologia estrella ");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement