Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. int Bfs_Bipartite(struct Graph* graph, int v)
  2. {
  3. graph->visited[v] = 1;
  4. graph->level[v] = 1;
  5.  
  6. struct Queue* queue = CreateQueue();
  7. enQueue(queue, v);
  8.  
  9. while(!isEmpty(queue))
  10. {
  11. int dequeueVertex = deQueue(queue);
  12. printf("nVisited vertex: %d", dequeueVertex);
  13. struct node* head = graph->adjList[dequeueVertex];
  14.  
  15. while(head)
  16. {
  17. int u = head->vertex;
  18. if(graph->level[u] == -1)
  19. {
  20. graph->visited[u] = 1;
  21. graph->level[u] = 1- graph->level[v];
  22. enQueue(queue, u);
  23. }
  24. else
  25.  
  26. if(graph->level[v] == graph->level[u])
  27. { printf("sdf");
  28. return 0;
  29. }
  30.  
  31. head = head->next;
  32.  
  33. }
  34. }
  35. return 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement