Grafalgo
Library of useful data structures and algorithms
|
00001 // usage: cgraph type 00002 // 00003 // Copy a graph of specified type from stdin to stdout. 00004 // Why you ask? To test input and output operators, of course. 00005 // We also do an assignment in between input and output, 00006 // in order to test the assignment operator. 00007 // 00008 // The allowed values of type are graph, wgraph, 00009 // digraph, wdigraph, flograph, wflograph. 00010 00011 #include "stdinc.h" 00012 #include "Adt.h" 00013 #include "Wgraph.h" 00014 #include "Wdigraph.h" 00015 #include "Wflograph.h" 00016 00017 using namespace grafalgo; 00018 00019 int main(int argc, char *argv[]) { 00020 00021 if (argc != 2) Util::fatal("usage: cgraph type"); 00022 00023 string s; 00024 if (strcmp(argv[1],"graph") == 0) { 00025 Graph g; cin >>g; Graph g1; 00026 g1.copyFrom(g); cout << g1; 00027 } else if (strcmp(argv[1],"wgraph") == 0) { 00028 Wgraph wg; cin >> wg; Wgraph wg1; 00029 wg1.copyFrom(wg); cout << wg1; 00030 } else if (strcmp(argv[1],"digraph") == 0) { 00031 Digraph dig; cin >> dig; Digraph dig1; 00032 dig1.copyFrom(dig); cout << dig1; 00033 } else if (strcmp(argv[1],"wdigraph") == 0) { 00034 Wdigraph wdig; cin >> wdig; Wdigraph wdig1; 00035 wdig1.copyFrom(wdig); cout << wdig1; 00036 } else if (strcmp(argv[1],"flograph") == 0) { 00037 Flograph fg; cin >> fg; Flograph fg1; 00038 fg1.copyFrom(fg); cout << fg1.toString(s); 00039 } else if (strcmp(argv[1],"wflograph") == 0) { 00040 Wflograph wfg; cin >> wfg; Wflograph wfg1; 00041 wfg1.copyFrom(wfg); cout << wfg1; 00042 } else { 00043 Util::fatal("usage: cgraph type"); 00044 } 00045 }