isl_tarjan.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef ISL_TARJAN_H
  2. #define ISL_TARJAN_H
  3. /* Structure for representing the nodes in the graph being traversed
  4. * using Tarjan's algorithm.
  5. * index represents the order in which nodes are visited.
  6. * min_index is the index of the root of a (sub)component.
  7. * on_stack indicates whether the node is currently on the stack.
  8. */
  9. struct isl_tarjan_node {
  10. int index;
  11. int min_index;
  12. int on_stack;
  13. };
  14. /* Structure for representing the graph being traversed
  15. * using Tarjan's algorithm.
  16. * len is the number of nodes
  17. * node is an array of nodes
  18. * stack contains the nodes on the path from the root to the current node
  19. * sp is the stack pointer
  20. * index is the index of the last node visited
  21. * order contains the elements of the components separated by -1
  22. * op represents the current position in order
  23. */
  24. struct isl_tarjan_graph {
  25. int len;
  26. struct isl_tarjan_node *node;
  27. int *stack;
  28. int sp;
  29. int index;
  30. int *order;
  31. int op;
  32. };
  33. struct isl_tarjan_graph *isl_tarjan_graph_init(isl_ctx *ctx, int len,
  34. isl_bool (*follows)(int i, int j, void *user), void *user);
  35. struct isl_tarjan_graph *isl_tarjan_graph_component(isl_ctx *ctx, int len,
  36. int node, isl_bool (*follows)(int i, int j, void *user), void *user);
  37. struct isl_tarjan_graph *isl_tarjan_graph_free(struct isl_tarjan_graph *g);
  38. #endif