Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

GraphIO.h
Go to the documentation of this file.
1 
33 #pragma once
34 
35 #include <ogdf/basic/exceptions.h>
36 #include <ogdf/basic/GridLayout.h>
39 #include <sstream>
40 
41 
42 namespace ogdf {
43 
44 
46 
49 class GraphIO
50 {
51 public:
53 
55  using ReaderFunc = bool (*)(Graph&, istream&);
56 
58  using WriterFunc = bool (*)(const Graph&, ostream&);
59 
61  using AttrReaderFunc = bool (*)(GraphAttributes&, Graph&, istream&);
62 
64  using AttrWriterFunc = bool (*)(const GraphAttributes&, ostream&);
65 
68  {
69  double m_margin;
71  double m_curviness;
73  string m_fontColor;
74  string m_fontFamily;
75  string m_width;
76  string m_height;
77 
78  public:
79  SVGSettings();
80 
82  bool bezierInterpolation() const { return m_bezierInterpolation; }
83 
85  double margin() const { return m_margin; }
86 
88  double curviness() const { return m_curviness; }
89 
91  int fontSize() const { return m_fontSize; }
92 
94  const string &fontColor() const { return m_fontColor; }
95 
97  const string &fontFamily() const { return m_fontFamily; }
98 
100  const string &width() const { return m_width; }
101 
103  const string &height() const { return m_height; }
104 
106  void margin(double m) { m_margin = m; }
107 
109  void curviness(double value) {
110  OGDF_ASSERT(value >= 0);
111  OGDF_ASSERT(value <= 1);
112 
113  m_curviness = value;
114  }
115 
117  void bezierInterpolation(bool enable) { m_bezierInterpolation = enable; }
118 
120  void fontSize(int fs) { m_fontSize = fs; }
121 
123  void fontColor(const string &fc) { m_fontColor = fc; }
124 
126  void fontFamily(const string &fm) { m_fontFamily = fm; }
127 
129 
132  void width(const string &width) { m_width = width; }
133 
135 
138  void height(const string &height) { m_height = height; }
139  };
140 
146 
148 
154  static inline bool read(Graph &G, const string &filename, ReaderFunc reader = GraphIO::read) {
155  ifstream is(filename);
156  return is.good() && reader(G, is);
157  }
158 
160 
166  static inline bool write(const Graph &G, const string &filename, WriterFunc writer) {
167  ofstream os(filename);
168  return os.good() && writer(G, os);
169  }
170 
172 
190  static OGDF_EXPORT bool read(Graph &G, istream &is);
191 
193 
200  static bool read(GraphAttributes &GA, Graph &G, const string &filename, AttrReaderFunc reader) {
201  ifstream is(filename);
202  return is.good() && reader(GA, G, is);
203  }
204 
206 
212  static bool write(const GraphAttributes &GA, const string &filename, AttrWriterFunc writer) {
213  ofstream os(filename);
214  return os.good() && writer(GA, os);
215  }
216 
217 #pragma mark GML
218 
220 
226 
228 
236  OGDF_DEPRECATED("Streams should be used instead.")
237  static OGDF_EXPORT bool readGML(Graph &G, const string &filename);
238 
240 
252  static OGDF_EXPORT bool readGML(Graph &G, istream &is);
253 
255 
263  OGDF_DEPRECATED("Streams should be used instead.")
264  static OGDF_EXPORT bool writeGML(const Graph &G, const string &filename);
265 
267 
279  static OGDF_EXPORT bool writeGML(const Graph &G, ostream &os);
280 
282 
292  OGDF_DEPRECATED("Streams should be used instead.")
293  static OGDF_EXPORT bool readGML(ClusterGraph &C, Graph &G, const string &filename);
294 
296 
305  static OGDF_EXPORT bool readGML(ClusterGraph &C, Graph &G, istream &is);
306 
308 
316  OGDF_DEPRECATED("Streams should be used instead.")
317  static OGDF_EXPORT bool writeGML(const ClusterGraph &C, const string &filename);
318 
320 
327  static OGDF_EXPORT bool writeGML(const ClusterGraph &C, ostream &os);
328 
330 
341  OGDF_DEPRECATED("Streams should be used instead.")
342  static OGDF_EXPORT bool readGML(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, const string &filename);
343 
345 
355  static OGDF_EXPORT bool readGML(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, istream &is);
356 
358 
366  OGDF_DEPRECATED("Streams should be used instead.")
367  static OGDF_EXPORT bool writeGML(const ClusterGraphAttributes &A, const string &filename);
368 
370 
377  static OGDF_EXPORT bool writeGML(const ClusterGraphAttributes &A, ostream &os);
378 
380 
390  OGDF_DEPRECATED("Streams should be used instead.")
391  static OGDF_EXPORT bool readGML(GraphAttributes &A, Graph &G, const string &filename);
392 
394 
403  static OGDF_EXPORT bool readGML(GraphAttributes &A, Graph &G, istream &is);
404 
406 
414  OGDF_DEPRECATED("Streams should be used instead.")
415  static OGDF_EXPORT bool writeGML(const GraphAttributes &A, const string &filename);
416 
418 
425  static OGDF_EXPORT bool writeGML(const GraphAttributes &A, ostream &os);
426 
427 #pragma mark OGML
428 
430 
436 
438 
446  OGDF_DEPRECATED("Streams should be used instead.")
447  static OGDF_EXPORT bool readOGML(Graph &G, const string &filename);
448 
450 
457  static OGDF_EXPORT bool readOGML(Graph &G, istream &is);
458 
460 
468  OGDF_DEPRECATED("Streams should be used instead.")
469  static OGDF_EXPORT bool writeOGML(const Graph &G, const string &filename);
470 
472 
479  static OGDF_EXPORT bool writeOGML(const Graph &G, ostream &os);
480 
482 
492  OGDF_DEPRECATED("Streams should be used instead.")
493  static OGDF_EXPORT bool readOGML(ClusterGraph &C, Graph &G, const string &filename);
494 
496 
505  static OGDF_EXPORT bool readOGML(ClusterGraph &C, Graph &G, istream &is);
506 
508 
516  OGDF_DEPRECATED("Streams should be used instead.")
517  static OGDF_EXPORT bool writeOGML(const ClusterGraph &C, const string &filename);
518 
520 
527  static OGDF_EXPORT bool writeOGML(const ClusterGraph &C, ostream &os);
528 
530 
540  OGDF_DEPRECATED("Streams should be used instead.")
541  static OGDF_EXPORT bool readOGML(GraphAttributes &A, Graph &G, const string &filename);
542 
544 
553  static OGDF_EXPORT bool readOGML(GraphAttributes &A, Graph &G, istream &is);
554 
556 
564  OGDF_DEPRECATED("Streams should be used instead.")
565  static OGDF_EXPORT bool writeOGML(const GraphAttributes &A, const string &filename);
566 
568 
575  static OGDF_EXPORT bool writeOGML(const GraphAttributes &A, ostream &os);
576 
578 
589  OGDF_DEPRECATED("Streams should be used instead.")
590  static OGDF_EXPORT bool readOGML(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, const string &filename);
591 
593 
603  static OGDF_EXPORT bool readOGML(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, istream &is);
604 
606 
614  OGDF_DEPRECATED("Streams should be used instead.")
615  static OGDF_EXPORT bool writeOGML(const ClusterGraphAttributes &A, const string &filename);
616 
618 
625  static OGDF_EXPORT bool writeOGML(const ClusterGraphAttributes &A, ostream &os);
626 
627 #pragma mark Rome
628 
630 
636 
638 
646  OGDF_DEPRECATED("Streams should be used instead.")
647  static OGDF_EXPORT bool readRome(Graph &G, const string &filename);
648 
650 
663  static OGDF_EXPORT bool readRome(Graph &G, istream &is);
664 
666 
674  OGDF_DEPRECATED("Streams should be used instead.")
675  static OGDF_EXPORT bool writeRome(const Graph &G, const string &filename);
676 
678 
685  static OGDF_EXPORT bool writeRome(const Graph &G, ostream &os);
686 
687 #pragma mark LEDA
688 
690 
696 
698 
706  OGDF_DEPRECATED("Streams should be used instead.")
707  static OGDF_EXPORT bool readLEDA(Graph &G, const string &filename);
708 
710 
723  static OGDF_EXPORT bool readLEDA(Graph &G, istream &is);
724 
726 
734  OGDF_DEPRECATED("Streams should be used instead.")
735  static OGDF_EXPORT bool writeLEDA(const Graph &G, const string &filename);
736 
738 
751  static OGDF_EXPORT bool writeLEDA(const Graph &G, ostream &os);
752 
753 #pragma mark Chaco
754 
756 
762 
764 
772  OGDF_DEPRECATED("Streams should be used instead.")
773  static OGDF_EXPORT bool readChaco(Graph &G, const string &filename);
774 
776 
789  static OGDF_EXPORT bool readChaco(Graph &G, istream &is);
790 
792 
800  OGDF_DEPRECATED("Streams should be used instead.")
801  static OGDF_EXPORT bool writeChaco(const Graph &G, const string &filename);
802 
804 
817  static OGDF_EXPORT bool writeChaco(const Graph &G, ostream &os);
818 
819 #pragma mark PMDissGraph
820 
822 
828 
830 
838  OGDF_DEPRECATED("Streams should be used instead.")
839  static OGDF_EXPORT bool readPMDissGraph(Graph &G, const string &filename);
840 
842 
857  static OGDF_EXPORT bool readPMDissGraph(Graph &G, istream &is);
858 
860 
868  OGDF_DEPRECATED("Streams should be used instead.")
869  static OGDF_EXPORT bool writePMDissGraph(const Graph &G, const string &filename);
870 
872 
887  static OGDF_EXPORT bool writePMDissGraph(const Graph &G, ostream &os);
888 
889 #pragma mark YGraph
890 
892 
898 
900 
907  OGDF_DEPRECATED("Streams should be used instead.")
908  static OGDF_EXPORT bool readYGraph(Graph &G, const string &filename);
909 
911 
931  static OGDF_EXPORT bool readYGraph(Graph &G, istream &is);
932 
933 #pragma mark Graph6
934 
936 
942 
944 
952  OGDF_DEPRECATED("Streams should be used instead.")
953  static OGDF_EXPORT bool readGraph6(Graph &G, const string &filename);
954 
956 
968  static OGDF_EXPORT bool readGraph6(Graph &G, istream &is);
969 
971 
979  OGDF_DEPRECATED("Streams should be used instead.")
980  static OGDF_EXPORT bool writeGraph6(const Graph &G, const string &filename);
981 
983 
995  static OGDF_EXPORT bool writeGraph6(const Graph &G, ostream &os);
996 
997 #pragma mark MatrixMarket
998 
1000 
1006 
1008 
1013  static OGDF_EXPORT bool readMatrixMarket(Graph& G, istream &inStream);
1014 
1016 
1021  OGDF_DEPRECATED("Streams should be used instead.")
1022  static OGDF_EXPORT bool readMatrixMarket(Graph& G, const string &filename);
1023 
1024 #pragma mark Rudy
1025 
1027 
1031 
1033 
1043  OGDF_DEPRECATED("Streams should be used instead.")
1044  static OGDF_EXPORT bool readRudy(GraphAttributes &A, Graph &G, const string &filename);
1045 
1047 
1056  static OGDF_EXPORT bool readRudy(GraphAttributes &A, Graph &G, istream &is);
1057 
1059 
1068  OGDF_DEPRECATED("Streams should be used instead.")
1069  static OGDF_EXPORT bool writeRudy(const GraphAttributes &A, const string &filename);
1070 
1072 
1080  static OGDF_EXPORT bool writeRudy(const GraphAttributes &A, ostream &os);
1081 
1082 #pragma mark BENCH
1083 
1085 
1089 
1091 
1108  OGDF_DEPRECATED("Streams should be used instead.")
1109  static OGDF_EXPORT bool readBENCH(Graph &G, List<node>& hypernodes, List<edge> *shell, const string &filename);
1110 
1112 
1129  static OGDF_EXPORT bool readBENCH(Graph &G, List<node>& hypernodes, List<edge> *shell, istream &is);
1130 
1131 #pragma mark PLA
1132 
1134 
1138 
1140 
1152  OGDF_DEPRECATED("Streams should be used instead.")
1153  static OGDF_EXPORT bool readPLA(Graph &G, List<node>& hypernodes, List<edge>* shell, const string &filename);
1154 
1156 
1173  static OGDF_EXPORT bool readPLA(Graph &G, List<node>& hypernodes, List<edge> *shell, istream &is);
1174 
1175 #pragma mark ChallengeGraph
1176 
1178 
1185 
1187 
1196  OGDF_DEPRECATED("Streams should be used instead.")
1197  static OGDF_EXPORT bool readChallengeGraph(Graph &G, GridLayout &gl, const string &filename);
1198 
1200 
1209  static OGDF_EXPORT bool readChallengeGraph(Graph &G, GridLayout &gl, istream &is);
1210 
1212 
1221  OGDF_DEPRECATED("Streams should be used instead.")
1222  static OGDF_EXPORT bool writeChallengeGraph(const Graph &G, const GridLayout &gl, const string &filename);
1223 
1225 
1234  static OGDF_EXPORT bool writeChallengeGraph(const Graph &G, const GridLayout &gl, ostream &os);
1235 
1236 #pragma mark GraphML
1237 
1239 
1245 
1247 
1255  OGDF_DEPRECATED("Streams should be used instead.")
1256  static OGDF_EXPORT bool readGraphML(Graph &G, const string &filename);
1257 
1259 
1266  static OGDF_EXPORT bool readGraphML(Graph &G, istream &is);
1267 
1269 
1279  OGDF_DEPRECATED("Streams should be used instead.")
1280  static OGDF_EXPORT bool readGraphML(ClusterGraph &C, Graph &G, const string &filename);
1281 
1283 
1292  static OGDF_EXPORT bool readGraphML(ClusterGraph &C, Graph &G, istream &is);
1293 
1295 
1305  OGDF_DEPRECATED("Streams should be used instead.")
1306  static OGDF_EXPORT bool readGraphML(GraphAttributes &A, Graph &G, const string &filename);
1307 
1309 
1318  static OGDF_EXPORT bool readGraphML(GraphAttributes &A, Graph &G, istream &is);
1319 
1321 
1332  OGDF_DEPRECATED("Streams should be used instead.")
1333  static OGDF_EXPORT bool readGraphML(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, const string &filename);
1334 
1336 
1346  static OGDF_EXPORT bool readGraphML(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, istream &is);
1347 
1349 
1357  OGDF_DEPRECATED("Streams should be used instead.")
1358  static OGDF_EXPORT bool writeGraphML(const Graph &G, const string &filename);
1359 
1361 
1367  static OGDF_EXPORT bool writeGraphML(const Graph &G, ostream &os);
1368 
1370 
1378  OGDF_DEPRECATED("Streams should be used instead.")
1379  static OGDF_EXPORT bool writeGraphML(const ClusterGraph &C, const string &filename);
1380 
1382 
1388  static OGDF_EXPORT bool writeGraphML(const ClusterGraph &C, ostream &os);
1389 
1391 
1399  OGDF_DEPRECATED("Streams should be used instead.")
1400  static OGDF_EXPORT bool writeGraphML(const GraphAttributes &A, const string &filename);
1401 
1403 
1409  static OGDF_EXPORT bool writeGraphML(const GraphAttributes &A, ostream &os);
1410 
1412 
1420  OGDF_DEPRECATED("Streams should be used instead.")
1421  static OGDF_EXPORT bool writeGraphML(const ClusterGraphAttributes &A, const string &filename);
1422 
1424 
1430  static OGDF_EXPORT bool writeGraphML(const ClusterGraphAttributes &A, ostream &os);
1431 
1432 #pragma mark DOT
1433 
1435 
1441 
1443 
1451  OGDF_DEPRECATED("Streams should be used instead.")
1452  static OGDF_EXPORT bool readDOT(Graph &G, const string &filename);
1453 
1455 
1462  static OGDF_EXPORT bool readDOT(Graph &G, istream &is);
1463 
1465 
1475  OGDF_DEPRECATED("Streams should be used instead.")
1476  static OGDF_EXPORT bool readDOT(ClusterGraph &C, Graph &G, const string &filename);
1477 
1479 
1488  static OGDF_EXPORT bool readDOT(ClusterGraph &C, Graph &G, istream &is);
1489 
1491 
1501  OGDF_DEPRECATED("Streams should be used instead.")
1502  static OGDF_EXPORT bool readDOT(GraphAttributes &A, Graph &G, const string &filename);
1503 
1505 
1514  static OGDF_EXPORT bool readDOT(GraphAttributes &A, Graph &G, istream &is);
1515 
1517 
1528  OGDF_DEPRECATED("Streams should be used instead.")
1529  static OGDF_EXPORT bool readDOT(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, const string &filename);
1530 
1532 
1542  static OGDF_EXPORT bool readDOT(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, istream &is);
1543 
1545 
1553  OGDF_DEPRECATED("Streams should be used instead.")
1554  static OGDF_EXPORT bool writeDOT(const Graph &G, const string &filename);
1555 
1557 
1563  static OGDF_EXPORT bool writeDOT(const Graph &G, ostream &os);
1564 
1566 
1574  OGDF_DEPRECATED("Streams should be used instead.")
1575  static OGDF_EXPORT bool writeDOT(const ClusterGraph &C, const string &filename);
1576 
1578 
1584  static OGDF_EXPORT bool writeDOT(const ClusterGraph &C, ostream &os);
1585 
1587 
1595  OGDF_DEPRECATED("Streams should be used instead.")
1596  static OGDF_EXPORT bool writeDOT(const GraphAttributes &A, const string &filename);
1597 
1599 
1605  static OGDF_EXPORT bool writeDOT(const GraphAttributes &A, ostream &os);
1606 
1608 
1616  OGDF_DEPRECATED("Streams should be used instead.")
1617  static OGDF_EXPORT bool writeDOT(const ClusterGraphAttributes &A, const string &filename);
1618 
1620 
1626  static OGDF_EXPORT bool writeDOT(const ClusterGraphAttributes &A, ostream &os);
1627 
1628 #pragma mark GEXF
1629 
1631 
1637 
1639 
1647  OGDF_DEPRECATED("Streams should be used instead.")
1648  static OGDF_EXPORT bool readGEXF(Graph &G, const string &filename);
1649 
1651 
1658  static OGDF_EXPORT bool readGEXF(Graph &G, istream &is);
1659 
1661 
1671  OGDF_DEPRECATED("Streams should be used instead.")
1672  static OGDF_EXPORT bool readGEXF(ClusterGraph &C, Graph &G, const string &filename);
1673 
1675 
1684  static OGDF_EXPORT bool readGEXF(ClusterGraph &C, Graph &G, istream &is);
1685 
1687 
1697  OGDF_DEPRECATED("Streams should be used instead.")
1698  static OGDF_EXPORT bool readGEXF(GraphAttributes &A, Graph &G, const string &filename);
1699 
1701 
1710  static OGDF_EXPORT bool readGEXF(GraphAttributes &A, Graph &G, istream &is);
1711 
1713 
1724  OGDF_DEPRECATED("Streams should be used instead.")
1725  static OGDF_EXPORT bool readGEXF(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, const string &filename);
1726 
1728 
1738  static OGDF_EXPORT bool readGEXF(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, istream &is);
1739 
1741 
1749  OGDF_DEPRECATED("Streams should be used instead.")
1750  static OGDF_EXPORT bool writeGEXF(const Graph &G, const string &filename);
1751 
1753 
1759  static OGDF_EXPORT bool writeGEXF(const Graph &G, ostream &os);
1760 
1762 
1770  OGDF_DEPRECATED("Streams should be used instead.")
1771  static OGDF_EXPORT bool writeGEXF(const ClusterGraph &C, const string &filename);
1772 
1774 
1780  static OGDF_EXPORT bool writeGEXF(const ClusterGraph &C, ostream &os);
1781 
1783 
1791  OGDF_DEPRECATED("Streams should be used instead.")
1792  static OGDF_EXPORT bool writeGEXF(const GraphAttributes &A, const string &filename);
1793 
1795 
1801  static OGDF_EXPORT bool writeGEXF(const GraphAttributes &A, ostream &os);
1802 
1804 
1812  OGDF_DEPRECATED("Streams should be used instead.")
1813  static OGDF_EXPORT bool writeGEXF(const ClusterGraphAttributes &A, const string &filename);
1814 
1816 
1822  static OGDF_EXPORT bool writeGEXF(const ClusterGraphAttributes &A, ostream &os);
1823 
1824 #pragma mark GDF
1825 
1827 
1833 
1835 
1843  OGDF_DEPRECATED("Streams should be used instead.")
1844  static OGDF_EXPORT bool readGDF(Graph &G, const string &filename);
1845 
1847 
1854  static OGDF_EXPORT bool readGDF(Graph &G, istream &is);
1855 
1857 
1867  OGDF_DEPRECATED("Streams should be used instead.")
1868  static OGDF_EXPORT bool readGDF(GraphAttributes &A, Graph &G, const string &filename);
1869 
1871 
1880  static OGDF_EXPORT bool readGDF(GraphAttributes &A, Graph &G, istream &is);
1881 
1883 
1891  OGDF_DEPRECATED("Streams should be used instead.")
1892  static OGDF_EXPORT bool writeGDF(const Graph &G, const string &filename);
1893 
1895 
1901  static OGDF_EXPORT bool writeGDF(const Graph &G, ostream &os);
1902 
1904 
1912  OGDF_DEPRECATED("Streams should be used instead.")
1913  static OGDF_EXPORT bool writeGDF(const GraphAttributes &A, const string &filename);
1914 
1916 
1922  static OGDF_EXPORT bool writeGDF(const GraphAttributes &A, ostream &os);
1923 
1924 #pragma mark TLP
1925 
1927 
1933 
1935 
1943  OGDF_DEPRECATED("Streams should be used instead.")
1944  static OGDF_EXPORT bool readTLP(Graph &G, const string &filename);
1945 
1947 
1954  static OGDF_EXPORT bool readTLP(Graph &G, istream &is);
1955 
1957 
1967  OGDF_DEPRECATED("Streams should be used instead.")
1968  static OGDF_EXPORT bool readTLP(ClusterGraph &C, Graph &G, const string &filename);
1969 
1971 
1980  static OGDF_EXPORT bool readTLP(ClusterGraph &C, Graph &G, istream &is);
1981 
1983 
1993  OGDF_DEPRECATED("Streams should be used instead.")
1994  static OGDF_EXPORT bool readTLP(GraphAttributes &A, Graph &G, const string &filename);
1995 
1997 
2006  static OGDF_EXPORT bool readTLP(GraphAttributes &A, Graph &G, istream &is);
2007 
2009 
2020  OGDF_DEPRECATED("Streams should be used instead.")
2021  static OGDF_EXPORT bool readTLP(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, const string &filename);
2022 
2024 
2034  static OGDF_EXPORT bool readTLP(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, istream &is);
2035 
2037 
2045  OGDF_DEPRECATED("Streams should be used instead.")
2046  static OGDF_EXPORT bool writeTLP(const Graph &G, const string &filename);
2047 
2049 
2055  static OGDF_EXPORT bool writeTLP(const Graph &G, ostream &os);
2056 
2058 
2066  OGDF_DEPRECATED("Streams should be used instead.")
2067  static OGDF_EXPORT bool writeTLP(const ClusterGraph &C, const string &filename);
2068 
2070 
2076  static OGDF_EXPORT bool writeTLP(const ClusterGraph &C, ostream &os);
2077 
2079 
2087  OGDF_DEPRECATED("Streams should be used instead.")
2088  static OGDF_EXPORT bool writeTLP(const GraphAttributes &A, const string &filename);
2089 
2091 
2097  static OGDF_EXPORT bool writeTLP(const GraphAttributes &A, ostream &os);
2098 
2100 
2108  OGDF_DEPRECATED("Streams should be used instead.")
2109  static OGDF_EXPORT bool writeTLP(const ClusterGraphAttributes &A, const string &filename);
2110 
2112 
2118  static OGDF_EXPORT bool writeTLP(const ClusterGraphAttributes &A, ostream &os);
2119 
2120 #pragma mark DL
2121 
2123 
2129 
2131 
2139  OGDF_DEPRECATED("Streams should be used instead.")
2140  static OGDF_EXPORT bool readDL(Graph &G, const string &filename);
2141 
2143 
2150  static OGDF_EXPORT bool readDL(Graph &G, istream &is);
2151 
2153 
2163  OGDF_DEPRECATED("Streams should be used instead.")
2164  static OGDF_EXPORT bool readDL(GraphAttributes &A, Graph &G, const string &filename);
2165 
2167 
2176  static OGDF_EXPORT bool readDL(GraphAttributes &A, Graph &G, istream &is);
2177 
2179 
2187  OGDF_DEPRECATED("Streams should be used instead.")
2188  static OGDF_EXPORT bool writeDL(const Graph &G, const string &filename);
2189 
2191 
2197  static OGDF_EXPORT bool writeDL(const Graph &G, ostream &os);
2198 
2200 
2208  OGDF_DEPRECATED("Streams should be used instead.")
2209  static OGDF_EXPORT bool writeDL(const GraphAttributes &A, const string &filename);
2210 
2212 
2218  static OGDF_EXPORT bool writeDL(const GraphAttributes &A, ostream &os);
2219 
2221 
2227 
2228 #pragma mark STP
2229 
2231 
2237 
2246  static OGDF_EXPORT bool readSTP(Graph &G, istream &is) {
2247  // ignore everything except for the unweighted graph itself
2249  List<node> terminals;
2250  NodeArray<bool> isTerminal;
2251  bool res = readSTP(wG, terminals, isTerminal, is);
2252  G = Graph(wG);
2253  return res;
2254  }
2255 
2267  template<typename T>
2268  OGDF_DEPRECATED("Streams should be used instead.")
2269  static bool readSTP(
2270  EdgeWeightedGraph<T> &wG,
2271  List<node> &terminals,
2272  NodeArray<bool> &isTerminal,
2273  const string &filename)
2274  {
2275  ifstream is(filename);
2276  return readSTP(wG, terminals, isTerminal, is);
2277  }
2278 
2290  template<typename T>
2291  static bool readSTP(
2293  List<node> &terminals,
2294  NodeArray<bool> &isTerminal,
2295  istream &is)
2296  {
2297  wG.clear();
2298  terminals.clear();
2299  isTerminal.init(wG);
2300  int expectedNumberOfTerminals = -1;
2301  int expectedNumberOfEdges = -1;
2302 
2303  string buffer;
2304 
2305  enum class Section {
2306  None,
2307  Comment,
2308  Graph,
2309  Terminals,
2310  Ignore, // mostly: not implemented
2311  } section = Section::None;
2312 
2313  string key, value;
2314 
2315  Array<node> indexToNode;
2316 #if 0
2317  node root; // root terminal (directed case)
2318 #endif
2319 
2320  double version;
2321 
2322  // 1. line = identifier; ignore that it must be all on the first line
2323  std::vector<string> firstline{"33D32945", "STP", "File,", "STP", "Format", "Version"};
2324  for (int i = 0; i < 6; ++i) {
2325  is >> buffer;
2326  if (!is.good() || !equalIgnoreCase(buffer, firstline[i])) {
2327  logger.lout() << "Could not parse first line." << endl;
2328  return false;
2329  }
2330  }
2331  is >> version;
2332  if (!is.good() || version != 1.0) {
2333  logger.lout() << "Encountered unknwon STP format version." << endl;
2334  return false;
2335  }
2336 
2337  while (std::getline(is, buffer)) {
2338  removeTrailingWhitespace(buffer);
2339 
2340  if (buffer.empty() || buffer[0] == '#') {
2341  continue;
2342  }
2343 
2344  std::istringstream iss(buffer);
2345  iss >> key;
2346  if (section != Section::None && equalIgnoreCase(key, "END")) {
2347  section = Section::None;
2348  continue;
2349  }
2350  switch (section) {
2351  case Section::None:
2352  if (equalIgnoreCase(key, "SECTION")) {
2353  string what;
2354  iss >> what;
2355  if (equalIgnoreCase(what, "Comment")) {
2356  section = Section::Comment;
2357  }
2358  else
2359  if (equalIgnoreCase(what, "Graph")) {
2360  if (wG.numberOfNodes() != 0) {
2361  logger.lout(Logger::Level::Minor) << "Encountered duplicate graph section.";
2362  section = Section::Ignore;
2363  } else {
2364  section = Section::Graph;
2365  }
2366  }
2367  else
2368  if (equalIgnoreCase(what, "Terminals")) {
2369  if (!terminals.empty()) {
2370  logger.lout(Logger::Level::Minor) << "Encountered duplicate terminal section.";
2371  section = Section::Ignore;
2372  } else {
2373  section = Section::Terminals;
2374  }
2375  }
2376  else {
2377  section = Section::Ignore;
2378  }
2379 
2380  if (!iss.eof()) {
2381  iss >> what;
2382  if (equalIgnoreCase(what, "FROM")) {
2383  // loading not implemented, just ignore and end section
2384  section = Section::None;
2385  }
2386  }
2387  }
2388  else
2389  if (equalIgnoreCase(buffer, "EOF")) {
2390  if(expectedNumberOfTerminals != -1 && expectedNumberOfTerminals != terminals.size()) {
2392  << "Invalid number of terminals. Was " << terminals.size()
2393  << " but expected " << expectedNumberOfTerminals << "." << endl;
2394  }
2395 
2396  if(expectedNumberOfEdges != -1 && expectedNumberOfEdges != wG.numberOfEdges()) {
2398  << "Invalid number of edges. Was " << wG.numberOfEdges()
2399  << " but expected " << expectedNumberOfEdges << "." << endl;
2400  }
2401  return true;
2402  }
2403  break;
2404 
2405  case Section::Ignore:
2406  case Section::Comment:
2407  // allow anything
2408  break;
2409 
2410  case Section::Graph:
2411  if (equalIgnoreCase(key, "Nodes")) {
2412  int n = -1;
2413  iss >> n;
2414  if (n < 0) {
2415  logger.lout() << "Invalid number of nodes specified: " << n << endl;
2416  return false;
2417  }
2418 
2419  indexToNode = Array<node>(1, n, nullptr);
2420  for (int i = 1; i <= n; ++i) {
2421  indexToNode[i] = wG.newNode();
2422  isTerminal[indexToNode[i]] = false;
2423  }
2424  } else if(equalIgnoreCase(key, "Edges") || equalIgnoreCase(key, "Arcs")) {
2425  iss >> expectedNumberOfEdges;
2426  } else if (equalIgnoreCase(key, "E")
2427  || equalIgnoreCase(key, "A")) {
2428  int source = -1, target = -1;
2429  T weight = -1;
2430  iss >> source >> target >> weight;
2431  if (source <= 0 || source > wG.numberOfNodes()
2432  || target <= 0 || target > wG.numberOfNodes()
2433  || weight < 0) {
2434  logger.lout() << "Invalid edge given: " << source << "->" << target << "(weight: " << weight << ")" << endl;
2435  return false;
2436  }
2437  wG.newEdge(indexToNode[source], indexToNode[target], weight);
2438  } else {
2439  logger.lout(Logger::Level::Minor) << "Invalid edge key encountered: " << key << endl;
2440  }
2441  break;
2442 
2443  case Section::Terminals:
2444  if (equalIgnoreCase(key, "Terminals")) {
2445  iss >> expectedNumberOfTerminals;
2446  } else if (equalIgnoreCase(key, "T")) {
2447  int v = -1;
2448  iss >> v;
2449  if (v <= 0 || v > wG.numberOfNodes()) {
2450  logger.lout() << "Invalid terminal encountered: " << v << endl;
2451  return false;
2452  }
2453  terminals.pushBack(indexToNode[v]);
2454  isTerminal[indexToNode[v]] = true;
2455  } else if(!equalIgnoreCase(key, "Root")) {
2456  logger.lout(Logger::Level::Minor) << "Invalid terminal key encountered: " << key << endl;
2457  }
2458  break;
2459  }
2460  }
2461  logger.lout() << "Unexpected end of file." << endl;
2462  return false;
2463  }
2464 
2476  template<typename T>
2477  OGDF_DEPRECATED("Streams should be used instead.")
2478  static bool writeSTP(
2479  const EdgeWeightedGraph<T> &wG,
2480  const List<node> &terminals,
2481  const string &filename,
2482  const string &comments = "")
2483  {
2484  ofstream os(filename);
2485  return writeSTP(wG, terminals, os, comments);
2486  }
2487 
2499  template<typename T>
2500  static bool writeSTP(
2501  const EdgeWeightedGraph<T> &wG,
2502  const List<node> &terminals,
2503  ostream &os,
2504  const string &comments = "")
2505  {
2506  if(!os.good()) return false;
2507 
2508  os << "33d32945 STP File, STP Format Version 1.00" << endl;
2509 
2510  os << endl << "Section Comment" << endl;
2511  if (comments.length() != 0) {
2512  os << comments << endl;
2513  }
2514  os << "End" << endl;
2515 
2516  os << endl << "Section Graph" << endl;
2517  os << "Nodes " << wG.numberOfNodes() << endl;
2518  os << "Edges " << wG.numberOfEdges() << endl;
2519 
2520  NodeArray<int> nodeToIndex(wG);
2521  int i = 1;
2522  for (node v : wG.nodes) {
2523  nodeToIndex[v] = i++;
2524  }
2525  for (edge e : wG.edges) {
2526  os << "E " << nodeToIndex[e->source()]
2527  << " " << nodeToIndex[e->target()]
2528  << " " << std::fixed << wG.weight(e) << endl;
2529  }
2530  os << "End" << endl
2531  << endl
2532  << "Section Terminals" << endl
2533  << "Terminals " << terminals.size() << endl;
2534  for (node v : terminals) {
2535  os << "T " << nodeToIndex[v] << endl;
2536  }
2537  os << "End" << endl
2538  << endl
2539  << "EOF" << endl;
2540 
2541  return true;
2542  }
2543 
2544 
2545 
2546 #pragma mark DMF
2547 
2549 
2555 
2566  template<typename T>
2567  OGDF_DEPRECATED("Streams should be used instead.")
2568  static bool readDMF(
2569  Graph &graph,
2570  EdgeArray<T> &weights,
2571  node &source,
2572  node &sink,
2573  const string &filename) {
2574  ifstream is(filename);
2575  return readDMF(graph, weights, source, sink, is);
2576  }
2577 
2588  template<typename T>
2589  static bool readDMF(
2590  Graph &graph,
2591  EdgeArray<T> &weights,
2592  node &source,
2593  node &sink,
2594  istream &is)
2595  {
2596  int expectedNumberOfEdges = -1;
2597  List<node> nodes;
2598  graph.clear();
2599  weights.init(graph, 0);
2600  source = nullptr;
2601  sink = nullptr;
2602 
2603  string buffer;
2604 
2605  while (std::getline(is, buffer)) {
2606  removeTrailingWhitespace(buffer);
2607  std::istringstream iss(buffer);
2608  string tmp;
2609  iss >> tmp;
2610 
2611  if (!buffer.empty() && buffer[0] != 'c') {
2612  if(buffer[0] == 'p') {
2613  // problem definition section
2614  if(!graph.empty()) {
2615  logger.lout() << "Ambigious problem definition encountered." << endl;
2616  return false;
2617  }
2618 
2619  string problemType = "";
2620  iss >> problemType;
2621  if(problemType.compare("max")) {
2622  logger.lout() << "Invalid problem type encountered: " << problemType << endl;
2623  return false;
2624  }
2625 
2626  int numberOfNodes = -1;
2627  iss >> numberOfNodes >> expectedNumberOfEdges;
2628 
2629  if(numberOfNodes < 2) {
2630  logger.lout() << "The given number of nodes is invalid (at least two)." << endl;
2631  return false;
2632  }
2633 
2634  if(expectedNumberOfEdges < 0) {
2635  logger.lout() << "The given number of edges is invalid." << endl;
2636  return false;
2637  }
2638 
2639  for(int i = 0; i < numberOfNodes; i++) {
2640  graph.newNode();
2641  }
2642  graph.allNodes(nodes);
2643  } else if(buffer[0] == 'n') {
2644  // target or source definition
2645  int nodeIndex = -1;
2646  string nodeTypeString = "";
2647  iss >> nodeIndex >> nodeTypeString;
2648 
2649  if (nodeIndex < 1 || nodeIndex > nodes.size()) {
2650  logger.lout() << "Invalid node index supplied: " << nodeIndex << endl;
2651  return false;
2652  }
2653 
2654  node w = *nodes.get(nodeIndex - 1);
2655  if (!nodeTypeString.compare("t")) {
2656  if(sink != nullptr) {
2657  logger.lout() << "Duplicate sink encountered: " << nodeTypeString << endl;
2658  return false;
2659  }
2660  sink = w;
2661  } else if (!nodeTypeString.compare("s")) {
2662  if(source != nullptr) {
2663  logger.lout() << "Duplicate source encountered: " << nodeTypeString << endl;
2664  return false;
2665  }
2666  source = w;
2667  } else {
2668  logger.lout() << "Malformed node type encountered: " << nodeTypeString << endl;
2669  return false;
2670  }
2671 
2672  } else if (buffer[0] == 'a') {
2673  // edge definition
2674  int sourceIndex = -1;
2675  int targetIndex = -1;
2676  T cap = -1;
2677 
2678  iss >> sourceIndex >> targetIndex >> cap;
2679 
2680  if (sourceIndex < 1 || sourceIndex > nodes.size()) {
2681  logger.lout() << "Invalid node index supplied: " << sourceIndex << endl;
2682  return false;
2683  }
2684  node newSource = *nodes.get(sourceIndex - 1);
2685 
2686  if (targetIndex < 1 || targetIndex > nodes.size()) {
2687  logger.lout() << "Invalid node index supplied: " << targetIndex << endl;
2688  return false;
2689  }
2690  node newTarget = *nodes.get(targetIndex - 1);
2691 
2692  if(cap < 0) {
2693  logger.lout() << "Negative capacity supplied: " << targetIndex << endl;
2694  return false;
2695  }
2696 
2697  edge e = graph.newEdge(newSource, newTarget);
2698  weights(e) = cap;
2699  } else {
2700  logger.lout() << "Encountered invalid line: " << buffer << endl;
2701  return false;
2702  }
2703  }
2704  }
2705 
2706  if (graph.empty()) {
2707  logger.lout() << "Missing problem definition." << endl;
2708  return false;
2709  }
2710 
2711  if (source == nullptr) {
2712  logger.lout() << "Missing source node." << endl;
2713  return false;
2714  }
2715 
2716  if(sink == nullptr) {
2717  logger.lout() << "Missing sink node." << endl;
2718  return false;
2719  }
2720 
2721  if(sink == source) {
2722  logger.lout() << "Source must be different from sink." << endl;
2723  return false;
2724  }
2725 
2726  if(expectedNumberOfEdges != graph.numberOfEdges()) {
2727  logger.lout() << "Invalid number of edges: expected " << expectedNumberOfEdges << " but was " << graph.numberOfEdges() << endl;
2728  return false;
2729  }
2730 
2731  return true;
2732  }
2733 
2745  template<typename T>
2746  OGDF_DEPRECATED("Streams should be used instead.")
2747  static bool writeDMF(
2748  const Graph &graph,
2749  const EdgeArray<T> &weights,
2750  const node source,
2751  const node sink,
2752  const string &filename)
2753  {
2754  ofstream os(filename);
2755  return writeDMF(graph, weights, source, sink, os);
2756  }
2757 
2769  template<typename T>
2770  static bool writeDMF(
2771  const Graph &graph,
2772  const EdgeArray<T> &weights,
2773  const node source,
2774  const node sink,
2775  ostream &os)
2776  {
2777  if(!os.good()) return false;
2778 
2779  NodeArray<int> nodeIndices(graph);
2780 
2781  int counter = 0;
2782  for(node v : graph.nodes) {
2783  nodeIndices[v] = ++counter;
2784  }
2785 
2786  os << "p max " << graph.numberOfNodes() << " " << graph.numberOfEdges() << endl;
2787  os << "n " << nodeIndices[source] << " s" << endl;
2788  os << "n " << nodeIndices[sink] << " t" << endl;
2789 
2790  for(edge e : graph.edges) {
2791  os << "a " << nodeIndices[e->source()] << " " << nodeIndices[e->target()] << " " << weights(e) << endl;
2792  }
2793 
2794  return true;
2795  }
2796 
2798 
2804 
2806 
2814  OGDF_DEPRECATED("Streams should be used instead.")
2815  static OGDF_EXPORT bool readEdgeListSubgraph(Graph &G, List<edge> &delEdges, const string &filename);
2816 
2818 
2826  static OGDF_EXPORT bool readEdgeListSubgraph(Graph &G, List<edge> &delEdges, istream &is);
2827 
2829 
2837  OGDF_DEPRECATED("Streams should be used instead.")
2838  static OGDF_EXPORT bool writeEdgeListSubgraph(const Graph &G, const List<edge> &delEdges, const string &filename);
2839 
2841 
2849  static OGDF_EXPORT bool writeEdgeListSubgraph(const Graph &G, const List<edge> &delEdges, ostream &os);
2850 
2852 
2857 
2858  OGDF_DEPRECATED("Streams should be used instead.")
2859  static OGDF_EXPORT bool drawSVG(const GraphAttributes &A, const string &filename, const SVGSettings &settings = svgSettings);
2860  static OGDF_EXPORT bool drawSVG(const GraphAttributes &A, ostream &os, const SVGSettings &settings);
2861  static inline bool drawSVG(const GraphAttributes &A, ostream &os) {
2862  return drawSVG(A, os, svgSettings);
2863  }
2864 
2865  OGDF_DEPRECATED("Streams should be used instead.")
2866  static OGDF_EXPORT bool drawSVG(const ClusterGraphAttributes &A, const string &filename, const SVGSettings &settings = svgSettings);
2867  static OGDF_EXPORT bool drawSVG(const ClusterGraphAttributes &A, ostream &os, const SVGSettings &settings);
2868  static inline bool drawSVG(const ClusterGraphAttributes &A, ostream &os) {
2869  return drawSVG(A, os, svgSettings);
2870  }
2871 
2873 
2879 
2881  static char indentChar() { return s_indentChar; }
2882 
2884  static int indentWidth() { return s_indentWidth; }
2885 
2887 
2890  static void setIndentChar(char c) {
2891  OGDF_ASSERT(isspace((int)c));
2892  s_indentChar = c;
2893  }
2894 
2896 
2900  static void setIndentWidth(int w) {
2901  if(w >= 0) s_indentWidth = w;
2902  }
2903 
2905  static OGDF_EXPORT ostream &indent(ostream &os, int depth);
2906 
2910 
2913  static OGDF_EXPORT bool setColorValue(int value, std::function<void(uint8_t)> setFunction)
2914  {
2915  if (value < 0 || value > 255) {
2916  GraphIO::logger.lout() << "Error: color value is not between 0 and 255." << endl;
2917  return false;
2918  }
2919  setFunction(static_cast<uint8_t>(value));
2920  return true;
2921  }
2922 
2924 
2926 
2927 private:
2930 };
2931 
2932 
2933 } // end namespace ogdf
static bool readSTP(EdgeWeightedGraph< T > &wG, List< node > &terminals, NodeArray< bool > &isTerminal, istream &is)
Reads a SteinLib instance from an inputstream is and converts it into a weighted graph wG and a set o...
Definition: GraphIO.h:2291
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:327
Representation of a graph&#39;s grid layout.
Definition: GridLayout.h:46
bool equalIgnoreCase(const string &str1, const string &str2)
Compares the two strings str1 and str2, ignoring the case of characters.
void clear()
Removes all elements from the list.
Definition: List.h:1394
static bool readGDF(Graph &G, const string &filename)
Reads graph G in GDF format from file filename.
static bool readYGraph(Graph &G, const string &filename)
Reads graph G in Y-graph format from file filename.
static ostream & indent(ostream &os, int depth)
Prints indentation for indentation depth to output stream os and returns os.
static bool write(const GraphAttributes &GA, const string &filename, AttrWriterFunc writer)
Writes arbitrary format to a file specified by name.
Definition: GraphIO.h:212
static bool writeDMF(const Graph &graph, const EdgeArray< T > &weights, const node source, const node sink, ostream &os)
Writes a maximum flow problem instance to a DIMACS maximum flow file.
Definition: GraphIO.h:2770
void curviness(double value)
Sets the curviness of all edges (value ranges from 0 to 1).
Definition: GraphIO.h:109
virtual void clear()
Removes all nodes and all edges from the graph.
void init()
Reinitializes the array. Associates the array with no graph.
Definition: EdgeArray.h:320
static void setIndentWidth(int w)
Sets the indentation width to w.
Definition: GraphIO.h:2900
iterator pushBack(const E &x)
Adds element x at the end of the list.
Definition: List.h:1316
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:472
static bool writeGML(const Graph &G, const string &filename)
Writes graph G in GML format to file filename.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
static const int Graph
Definition: GmlParser.h:59
void init()
Reinitializes the array. Associates the array with no graph.
Definition: NodeArray.h:292
static bool writeDL(const Graph &G, const string &filename)
Writes graph G in DL format to file filename.
static bool readGEXF(Graph &G, const string &filename)
Reads graph G in GEXF format from file filename.
double curviness() const
Returns the curviness of the edges (value ranges from 0 to 1).
Definition: GraphIO.h:88
static bool readRudy(GraphAttributes &A, Graph &G, const string &filename)
Reads graph G with edge weights stored in A in Rudy format from file filename.
Utility class providing graph I/O in various exchange formats.
Definition: GraphIO.h:49
bool(*)(const Graph &, ostream &) WriterFunc
Type of simple graph writer functions working on streams.
Definition: GraphIO.h:58
static bool drawSVG(const GraphAttributes &A, ostream &os)
Definition: GraphIO.h:2861
static bool writeChallengeGraph(const Graph &G, const GridLayout &gl, const string &filename)
Writes graph G with grid layout gl in GD-Challenge-format to file filename.
Dynamic arrays indexed with edges.
Definition: EdgeArray.h:112
static bool writeGraphML(const Graph &G, const string &filename)
Writes graph G in GraphML format to file filename.
static bool readPLA(Graph &G, List< node > &hypernodes, List< edge > *shell, const string &filename)
Reads a hypergraph (as point-based expansion) in PLA format from file filename.
static bool readGraphML(Graph &G, const string &filename)
Reads graph G in GraphML format from file filename.
static bool writeEdgeListSubgraph(const Graph &G, const List< edge > &delEdges, const string &filename)
Writes graph G with subgraph defined by delEdges to file filename.
static bool readTLP(Graph &G, const string &filename)
Reads graph G in TLP format from file filename.
T weight(const edge e) const
static bool readPMDissGraph(Graph &G, const string &filename)
Reads graph G in a simple format as used in Petra Mutzel&#39;s thesis from file filename.
static bool readDL(Graph &G, const string &filename)
Reads graph G in DL format from file filename.
std::ostream & lout(Level l=Level::Default) const
stream for logging-output (local)
Definition: Logger.h:147
bool(*)(Graph &, istream &) ReaderFunc
Type of simple graph reader functions working on streams.
Definition: GraphIO.h:55
bool(*)(GraphAttributes &, Graph &, istream &) AttrReaderFunc
Type of simple graph attributes reader functions working on streams.
Definition: GraphIO.h:61
static bool readGML(Graph &G, const string &filename)
Reads graph G in GML format from file filename.
static bool readEdgeListSubgraph(Graph &G, List< edge > &delEdges, const string &filename)
Reads graph G with subgraph defined by delEdges from file filename.
edge newEdge(node v, node w, T weight)
Representation of clustered graphs.
Definition: ClusterGraph.h:291
static bool readChallengeGraph(Graph &G, GridLayout &gl, const string &filename)
Reads graph G with grid layout gl in GD-Challenge-format from file filename.
static bool readBENCH(Graph &G, List< node > &hypernodes, List< edge > *shell, const string &filename)
Reads a hypergraph (as point-based expansion) in BENCH format from file filename. ...
static bool writeGEXF(const Graph &G, const string &filename)
Writes graph G in GEXF format to file filename.
static bool read(GraphAttributes &GA, Graph &G, const string &filename, AttrReaderFunc reader)
Reads arbitrary format from a file specified by name.
Definition: GraphIO.h:200
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Definition: Graph_d.h:548
int numberOfEdges() const
Returns the number of edges in the graph.
Definition: Graph_d.h:581
void removeTrailingWhitespace(string &str)
Removes trailing space, horizontal and vertical tab, feed, newline, and carriage return from str...
static void setIndentChar(char c)
Sets the indentation character to c.
Definition: GraphIO.h:2890
static SVGSettings svgSettings
Definition: GraphIO.h:2925
static bool writeGraph6(const Graph &G, const string &filename)
Writes graph G in Graph6 format to file filename.
static bool writeGDF(const Graph &G, const string &filename)
Writes graph G in GDF format to file filename.
static char s_indentChar
Character used for indentation.
Definition: GraphIO.h:2928
static bool writeTLP(const Graph &G, const string &filename)
Writes graph G in TLP format to file filename.
static bool setColorValue(int value, std::function< void(uint8_t)> setFunction)
Set a color value (R/G/B/A) based on an integer. Checks if the value is in the right range...
Definition: GraphIO.h:2913
Declaration of class GridLayout.
Stores additional attributes of a graph (like layout information).
static bool readDMF(Graph &graph, EdgeArray< T > &weights, node &source, node &sink, const string &filename)
Reads a maximum flow instance in DIMACS format.
Definition: GraphIO.h:2568
Doubly linked lists (maintaining the length of the list).
Definition: List.h:39
edge newEdge(node v, node w)
Creates a new edge (v,w) and returns it.
Definition of exception classes.
const string & width() const
Returns the default width.
Definition: GraphIO.h:100
int fontSize() const
Returns the default font size (font height in pixels).
Definition: GraphIO.h:91
Class for the representation of edges.
Definition: Graph_d.h:291
static bool readDOT(Graph &G, const string &filename)
Reads graph G in DOT format from file filename.
Stores additional attributes of a clustered graph (like layout information).
Declaration of class EdgeWeightedGraph.
static bool writeSTP(const EdgeWeightedGraph< T > &wG, const List< node > &terminals, ostream &os, const string &comments="")
Writes an Steiner problem instance to an STP file.
Definition: GraphIO.h:2500
static bool readSTP(Graph &G, istream &is)
Reads a graph in SteinLib format from istream is.
Definition: GraphIO.h:2246
const string & height() const
Returns the default height.
Definition: GraphIO.h:103
static bool writePMDissGraph(const Graph &G, const string &filename)
Writes graph G in a simple format as used in Petra Mutzel&#39;s thesis to file filename.
const_iterator get(int pos) const
Returns a const iterator pointing to the element at position pos.
Definition: List.h:290
double margin() const
Returns the size of the margin around the drawing.
Definition: GraphIO.h:85
Class for the representation of nodes.
Definition: Graph_d.h:167
static bool writeChaco(const Graph &G, const string &filename)
Writes graph G in Chaco format to file filename.
void height(const string &height)
Sets the height.
Definition: GraphIO.h:138
void fontSize(int fs)
Sets the default font size (font height in pixels) to fs.
Definition: GraphIO.h:120
void width(const string &width)
Sets the width.
Definition: GraphIO.h:132
static bool drawSVG(const ClusterGraphAttributes &A, ostream &os)
Definition: GraphIO.h:2868
static bool readDMF(Graph &graph, EdgeArray< T > &weights, node &source, node &sink, istream &is)
Reads a maximum flow instance in DIMACS format.
Definition: GraphIO.h:2589
Declares ClusterGraphAttributes, an extension of class GraphAttributes, to store clustergraph layout ...
void margin(double m)
Sets the size of the margin around the drawing to m.
Definition: GraphIO.h:106
static int s_indentWidth
Number of indent characters used for indentation.
Definition: GraphIO.h:2929
static bool readMatrixMarket(Graph &G, istream &inStream)
Reads graph G in Matrix Market exchange format from stream inStream.
static bool readChaco(Graph &G, const string &filename)
Reads graph G in Chaco format from file filename.
Condensed settings for drawing SVGs.
Definition: GraphIO.h:67
Centralized global and local logging facility working on streams like cout.
Definition: Logger.h:99
bool bezierInterpolation() const
Returns whether Bézier-interpolation for curved edges is enabled.
Definition: GraphIO.h:82
static bool write(const Graph &G, const string &filename, WriterFunc writer)
Writes arbitrary format to a file specified by name.
Definition: GraphIO.h:166
int size() const
Returns the number of elements in the list.
Definition: List.h:1255
static bool writeOGML(const Graph &G, const string &filename)
Writes graph G in OGML format to file filename.
static int indentWidth()
Returns the currently used indentation width.
Definition: GraphIO.h:2884
const string & fontFamily() const
Returns the default font family.
Definition: GraphIO.h:97
void allNodes(NODELIST &nodeList) const
Returns a list with all nodes of the graph.
Definition: Graph_d.h:631
static bool readGraph6(Graph &G, const string &filename)
Reads graph G in Graph6 format from file filename.
#define OGDF_DEPRECATED(reason)
Mark a class / member / function as deprecated.
Definition: config.h:118
void fontFamily(const string &fm)
Sets the default font family to fm.
Definition: GraphIO.h:126
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:325
void fontColor(const string &fc)
Sets the default font color to fc.
Definition: GraphIO.h:123
void bezierInterpolation(bool enable)
Enables or disables Bézier-interpolation.
Definition: GraphIO.h:117
The namespace for all OGDF objects.
static bool writeRudy(const GraphAttributes &A, const string &filename)
Writes graph with edge weights stored in A in Rudy format to file filename.
const string & fontColor() const
Returns the default font color.
Definition: GraphIO.h:94
static bool writeDOT(const Graph &G, const string &filename)
Writes graph G in DOT format to file filename.
int numberOfNodes() const
Returns the number of nodes in the graph.
Definition: Graph_d.h:578
static bool readLEDA(Graph &G, const string &filename)
Reads graph G in LEDA graph format from file filename.
node newNode()
Creates a new node and returns it.
static bool writeRome(const Graph &G, const string &filename)
Writes graph G in Rome-Lib format to file filename.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Definition: Graph_d.h:545
static bool writeLEDA(const Graph &G, const string &filename)
Writes graph G in LEDA graph format to file filename.
static bool writeSTP(const EdgeWeightedGraph< T > &wG, const List< node > &terminals, const string &filename, const string &comments="")
Writes an Steiner problem instance to an STP file.
Definition: GraphIO.h:2478
static bool readOGML(Graph &G, const string &filename)
Reads graph G in OGML format from file filename.
static bool drawSVG(const GraphAttributes &A, const string &filename, const SVGSettings &settings=svgSettings)
static char indentChar()
Returns the currently used indentation character.
Definition: GraphIO.h:2881
bool empty() const
Returns true iff the list is empty.
Definition: List.h:236
bool empty() const
Returns true iff the graph is empty, i.e., contains no nodes.
Definition: Graph_d.h:575
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:41
static bool read(Graph &G, const string &filename, ReaderFunc reader=GraphIO::read)
Reads arbitrary format from a file specified by name.
Definition: GraphIO.h:154
static bool readRome(Graph &G, const string &filename)
Reads graph G in Rome-Lib format from file filename.
static bool writeDMF(const Graph &graph, const EdgeArray< T > &weights, const node source, const node sink, const string &filename)
Writes a maximum flow problem instance to a DIMACS maximum flow file.
Definition: GraphIO.h:2747
bool(*)(const GraphAttributes &, ostream &) AttrWriterFunc
Type of simple graph attributes writer functions working on streams.
Definition: GraphIO.h:64
static Logger logger
Definition: GraphIO.h:52