Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void graphviz_output_2(int n, int *result, int c, int** x, int st)
- {
- int count = 0;
- for (int i = 0; i < c; i++) {
- if (result[i] == -1) count++;
- }
- int **y;
- y = new int*[n];
- for (int i = 0; i < n; i++) y[i] = new int[n];
- int q = 0;
- for (int p = 0; p < count; p++) {
- char strout[100] = "C:\\Users\\Tuhlomon\\Desktop\\graph_output";
- char num[5] = { 0 };
- _itoa(p, num, 10);
- strcat(strout, num);
- strcat(strout, ".gv");
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- y[i][j] = x[i][j];
- }
- }
- ofstream fout(strout);
- fout << "digraph OutputGraph" << endl << "{" << endl;
- for (int r = 0; r < n; r++) {
- if (r == st) continue;
- fout << r << ";";
- }
- fout << endl;
- fout << st << " [style=filled, fillcolor=red];";
- fout << endl;
- fout << "edge [color=red];" << endl;
- for (; q<c; q++) {
- if (result[q + 1] == -1) {
- q++; break;
- }
- if ((result[q + 1] != -1) && (result[q] != -1) && (y[result[q]][result[q + 1]] != 0)) {
- fout << result[q] << "->" << result[q + 1] << endl;
- y[result[q]][result[q + 1]] = 0;
- }
- else continue;
- }
- fout << "edge [color=black];" << endl;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- if (y[i][j] != 0) fout << i << "->" << j << endl;
- }
- }
- fout << "}" << endl;
- fout.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement