Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. void graphviz_output_2(int n, int *result, int c, int** x, int st)
  2. {
  3. int count = 0;
  4. for (int i = 0; i < c; i++) {
  5. if (result[i] == -1) count++;
  6. }
  7. int **y;
  8. y = new int*[n];
  9. for (int i = 0; i < n; i++) y[i] = new int[n];
  10. int q = 0;
  11. for (int p = 0; p < count; p++) {
  12. char strout[100] = "C:\\Users\\Tuhlomon\\Desktop\\graph_output";
  13. char num[5] = { 0 };
  14. _itoa(p, num, 10);
  15. strcat(strout, num);
  16. strcat(strout, ".gv");
  17. for (int i = 0; i < n; i++) {
  18. for (int j = 0; j < n; j++) {
  19. y[i][j] = x[i][j];
  20. }
  21. }
  22. ofstream fout(strout);
  23. fout << "digraph OutputGraph" << endl << "{" << endl;
  24. for (int r = 0; r < n; r++) {
  25. if (r == st) continue;
  26. fout << r << ";";
  27. }
  28. fout << endl;
  29. fout << st << " [style=filled, fillcolor=red];";
  30. fout << endl;
  31. fout << "edge [color=red];" << endl;
  32. for (; q<c; q++) {
  33. if (result[q + 1] == -1) {
  34. q++; break;
  35. }
  36. if ((result[q + 1] != -1) && (result[q] != -1) && (y[result[q]][result[q + 1]] != 0)) {
  37. fout << result[q] << "->" << result[q + 1] << endl;
  38. y[result[q]][result[q + 1]] = 0;
  39. }
  40. else continue;
  41. }
  42. fout << "edge [color=black];" << endl;
  43. for (int i = 0; i < n; i++) {
  44. for (int j = 0; j < n; j++) {
  45. if (y[i][j] != 0) fout << i << "->" << j << endl;
  46. }
  47. }
  48. fout << "}" << endl;
  49. fout.close();
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement