| 18 | |
| 19 | |
| 20 | int main (int argc, const char * argv[]) |
| 21 | { |
| 22 | if (argc < 2) |
| 23 | { |
| 24 | cout << "Usage: script <file-name>" << endl; |
| 25 | exit(1); |
| 26 | } |
| 27 | char filename[256]; |
| 28 | strcpy (filename, argv[1]); |
| 29 | |
| 30 | // --------------------------------------------------------- |
| 31 | // Read graph |
| 32 | |
| 33 | MyGraph G; |
| 34 | |
| 35 | GML_error err = G.load (filename); |
| 36 | if (err.err_num != GML_OK) |
| 37 | { |
| 38 | cerr << "Error (" << err.err_num << ") loading graph from file \"" << filename << "\""; |
| 39 | switch (err.err_num) |
| 40 | { |
| 41 | case GML_FILE_NOT_FOUND: cerr << "A file with that name doesn't exist."; break; |
| 42 | case GML_TOO_MANY_BRACKETS: cerr << "A mismatch of brackets was detected, i.e. there were too many closing brackets (])."; break; |
| 43 | case GML_OPEN_BRACKET: cerr << "Now, there were too many opening brackets ([)"; break; |
| 44 | case GML_TOO_MANY_DIGITS: cerr << "The number of digits a integer or floating point value can have is limited to 1024, this should be enough :-)"; break; |
| 45 | case GML_PREMATURE_EOF: cerr << "An EOF occured, where it wasn't expected, e.g. while scanning a string."; break; |
| 46 | case GML_SYNTAX: cerr << "The file isn't a valid GML file, e.g. a mismatch in the key-value pairs."; break; |
| 47 | case GML_UNEXPECTED: cerr << "A character occured, where it makes no sense, e.g. non-numerical characters"; break; |
| 48 | case GML_OK: break; |
| 49 | } |
| 50 | cerr << endl; |
| 51 | exit(1); |
| 52 | } |
| 53 | else |
| 54 | { |
| 55 | cout << "Graph read from file \"" << filename << "\" has " << G.number_of_nodes() << " nodes and " << G.number_of_edges() << " edges" << endl; |
| 56 | } |
| 57 | |
| 58 | |
| 59 | // Output starting graph |
| 60 | G.save_dot ("start.dot"); |
| 61 | |
| 62 | |
| 63 | // 1. Get map between labels and nodes |
| 64 | std::map < std::string, GTL::node, std::less<std::string> > l; |
| 65 | node n; |
| 66 | forall_nodes (n, G) |
| 67 | { |
| 68 | l[G.get_node_label(n)] = n; |
| 69 | } |
| 70 | |
| 71 | // Read edit script |
| 72 | { |
| 73 | ifstream f ("script.txt"); |
| 74 | char buf[512]; |
| 75 | |
| 76 | while (f.good()) |
| 77 | { |
nothing calls this directly
no test coverage detected