Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

GraphIO.h
Go to the documentation of this file.
1 
33 #pragma once
34 
35 #include <ogdf/basic/GridLayout.h>
36 #include <ogdf/basic/exceptions.h>
39 
40 #include <sstream>
41 #include <unordered_map>
42 
43 namespace ogdf {
44 
45 
47 
50 class GraphIO {
51 public:
53 
55  using ReaderFunc = bool (*)(Graph&, std::istream&);
56 
58  using WriterFunc = bool (*)(const Graph&, std::ostream&);
59 
61  using AttrReaderFunc = bool (*)(GraphAttributes&, Graph&, std::istream&);
62 
64  using AttrWriterFunc = bool (*)(const GraphAttributes&, std::ostream&);
65 
67  using ClusterReaderFunc = bool (*)(ClusterGraph&, Graph&, std::istream&);
68 
70  using ClusterWriterFunc = bool (*)(const ClusterGraph&, std::ostream&);
71 
74  std::istream&);
75 
77  using ClusterAttrWriterFunc = bool (*)(const ClusterGraphAttributes&, std::ostream&);
78 
79  struct FileType {
80  std::vector<std::string> extensions;
93 
94  explicit FileType(std::vector<std::string> extensions, ReaderFunc readerFunc = nullptr,
95  WriterFunc writerFunc = nullptr, AttrReaderFunc attrReaderFunc = nullptr,
96  AttrWriterFunc attrWriterFunc = nullptr,
97  ClusterReaderFunc clusterReaderFunc = nullptr,
98  ClusterWriterFunc clusterWriterFunc = nullptr,
99  ClusterAttrReaderFunc clusterAttrReaderFunc = nullptr,
100  ClusterAttrWriterFunc clusterAttrWriterFunc = nullptr);
101 
102  FileType& replaceAutoReaders(ReaderFunc readerFunc = nullptr,
103  AttrReaderFunc attrReaderFunc = nullptr,
104  ClusterReaderFunc clusterReaderFunc = nullptr,
105  ClusterAttrReaderFunc clusterAttrReaderFunc = nullptr);
106  };
107 
108  static const OGDF_EXPORT std::vector<FileType> FILE_TYPES;
109  static OGDF_EXPORT std::unordered_map<string, const FileType*> FILE_TYPE_MAP;
110 
111  static OGDF_EXPORT const std::unordered_map<string, const FileType*>& getFileTypeMap();
112 
113  static OGDF_EXPORT const FileType* getFileType(const string& filename);
114 
117  double m_margin;
119  double m_curviness;
121  string m_fontColor;
122  string m_fontFamily;
123  string m_width;
124  string m_height;
125 
126  public:
127  SVGSettings();
128 
130  bool bezierInterpolation() const { return m_bezierInterpolation; }
131 
133  double margin() const { return m_margin; }
134 
136  double curviness() const { return m_curviness; }
137 
139  int fontSize() const { return m_fontSize; }
140 
142  const string& fontColor() const { return m_fontColor; }
143 
145  const string& fontFamily() const { return m_fontFamily; }
146 
148  const string& width() const { return m_width; }
149 
151  const string& height() const { return m_height; }
152 
154  void margin(double m) { m_margin = m; }
155 
157  void curviness(double value) {
158  OGDF_ASSERT(value >= 0);
159  OGDF_ASSERT(value <= 1);
160 
161  m_curviness = value;
162  }
163 
165  void bezierInterpolation(bool enable) { m_bezierInterpolation = enable; }
166 
168  void fontSize(int fs) { m_fontSize = fs; }
169 
171  void fontColor(const string& fc) { m_fontColor = fc; }
172 
174  void fontFamily(const string& fm) { m_fontFamily = fm; }
175 
177 
180  void width(const string& width) { m_width = width; }
181 
183 
186  void height(const string& height) { m_height = height; }
187  };
188 
307 
318  static OGDF_EXPORT bool read(Graph& G, const string& filename, ReaderFunc reader = nullptr);
319 
330  static OGDF_EXPORT bool read(GraphAttributes& GA, Graph& G, const string& filename,
331  AttrReaderFunc reader = nullptr);
332 
343  static OGDF_EXPORT bool read(ClusterGraph& CG, Graph& G, const string& filename,
344  ClusterReaderFunc reader = nullptr);
345 
359  static OGDF_EXPORT bool read(ClusterGraphAttributes& GA, ClusterGraph& CG, Graph& G,
360  const string& filename, ClusterAttrReaderFunc reader = nullptr);
361 
371  static OGDF_EXPORT bool read(Graph& G, std::istream& is);
372 
383  static OGDF_EXPORT bool read(GraphAttributes& GA, Graph& G, std::istream& is);
384 
395  static OGDF_EXPORT bool read(ClusterGraph& CG, Graph& G, std::istream& is);
396 
410  static OGDF_EXPORT bool read(ClusterGraphAttributes& GA, ClusterGraph& CG, Graph& G,
411  std::istream& is);
412 
421  static OGDF_EXPORT bool write(const Graph& G, const string& filename,
422  WriterFunc writer = nullptr);
423 
432  static OGDF_EXPORT bool write(const GraphAttributes& GA, const string& filename,
433  AttrWriterFunc writer = nullptr);
434 
443  static OGDF_EXPORT bool write(const ClusterGraph& CG, const string& filename,
444  ClusterWriterFunc writer = nullptr);
445 
456  static OGDF_EXPORT bool write(const ClusterGraphAttributes& GA, const string& filename,
457  ClusterAttrWriterFunc writer = nullptr);
458 
460 
461 #pragma mark GML
462 
467 
470 
482  static OGDF_EXPORT bool readGML(Graph& G, std::istream& is);
483 
485 
497  static OGDF_EXPORT bool writeGML(const Graph& G, std::ostream& os);
498 
500 
509  static OGDF_EXPORT bool readGML(ClusterGraph& C, Graph& G, std::istream& is);
510 
512 
519  static OGDF_EXPORT bool writeGML(const ClusterGraph& C, std::ostream& os);
520 
522 
533  std::istream& is);
534 
536 
543  static OGDF_EXPORT bool writeGML(const ClusterGraphAttributes& A, std::ostream& os);
544 
546 
555  static OGDF_EXPORT bool readGML(GraphAttributes& A, Graph& G, std::istream& is);
556 
558 
565  static OGDF_EXPORT bool writeGML(const GraphAttributes& A, std::ostream& os);
566 
568 
569 #pragma mark Rome
570 
575 
578 
591  static OGDF_EXPORT bool readRome(Graph& G, std::istream& is);
592 
594 
601  static OGDF_EXPORT bool writeRome(const Graph& G, std::ostream& os);
602 
604 
605 #pragma mark LEDA
606 
611 
614 
627  static OGDF_EXPORT bool readLEDA(Graph& G, std::istream& is);
628 
630 
643  static OGDF_EXPORT bool writeLEDA(const Graph& G, std::ostream& os);
644 
646 
647 #pragma mark Chaco
648 
653 
656 
669  static OGDF_EXPORT bool readChaco(Graph& G, std::istream& is);
670 
672 
685  static OGDF_EXPORT bool writeChaco(const Graph& G, std::ostream& os);
686 
688 
689 #pragma mark PMDissGraph
690 
695 
698 
713  static OGDF_EXPORT bool readPMDissGraph(Graph& G, std::istream& is);
714 
716 
731  static OGDF_EXPORT bool writePMDissGraph(const Graph& G, std::ostream& os);
732 
734 
735 #pragma mark YGraph
736 
741 
744 
764  static OGDF_EXPORT bool readYGraph(Graph& G, std::istream& is);
765 
767 
768 #pragma mark Graph6
769 
777 
780 
788  static OGDF_EXPORT bool readGraph6(Graph& G, std::istream& is, bool forceHeader = false);
789 
791 
798  static OGDF_EXPORT bool writeGraph6(const Graph& G, std::ostream& os);
799 
801 
802 #pragma mark Digraph6
803 
810 
813 
821  static OGDF_EXPORT bool readDigraph6(Graph& G, std::istream& is, bool forceHeader = false);
822 
824 
831  static OGDF_EXPORT bool writeDigraph6(const Graph& G, std::ostream& os);
832 
834 
835 #pragma mark Sparse6
836 
843 
846 
854  static OGDF_EXPORT bool readSparse6(Graph& G, std::istream& is, bool forceHeader = false);
855 
857 
864  static OGDF_EXPORT bool writeSparse6(const Graph& G, std::ostream& os);
865 
867 
868 #pragma mark MatrixMarket
869 
874 
877 
882  static OGDF_EXPORT bool readMatrixMarket(Graph& G, std::istream& inStream);
883 
885 
886 #pragma mark Rudy
887 
890 
893 
902  static OGDF_EXPORT bool readRudy(GraphAttributes& A, Graph& G, std::istream& is);
903 
905 
912  static OGDF_EXPORT bool readRudy(Graph& G, std::istream& is) {
914  return readRudy(A, G, is);
915  }
916 
918 
926  static OGDF_EXPORT bool writeRudy(const GraphAttributes& A, std::ostream& os);
927 
929 
930 #pragma mark BENCH
931 
934 
937 
954  static OGDF_EXPORT bool readBENCH(Graph& G, List<node>& hypernodes, List<edge>* shell,
955  std::istream& is);
956 
958 
959 #pragma mark PLA
960 
963 
966 
983  static OGDF_EXPORT bool readPLA(Graph& G, List<node>& hypernodes, List<edge>* shell,
984  std::istream& is);
985 
987 
988 #pragma mark ChallengeGraph
989 
995 
998 
1007  static OGDF_EXPORT bool readChallengeGraph(Graph& G, GridLayout& gl, std::istream& is);
1008 
1010 
1019  static OGDF_EXPORT bool writeChallengeGraph(const Graph& G, const GridLayout& gl,
1020  std::ostream& os);
1021 
1023 
1024 #pragma mark GraphML
1025 
1030 
1033 
1040  static OGDF_EXPORT bool readGraphML(Graph& G, std::istream& is);
1041 
1043 
1052  static OGDF_EXPORT bool readGraphML(ClusterGraph& C, Graph& G, std::istream& is);
1053 
1055 
1064  static OGDF_EXPORT bool readGraphML(GraphAttributes& A, Graph& G, std::istream& is);
1065 
1067 
1078  std::istream& is);
1079 
1081 
1087  static OGDF_EXPORT bool writeGraphML(const Graph& G, std::ostream& os);
1088 
1090 
1096  static OGDF_EXPORT bool writeGraphML(const ClusterGraph& C, std::ostream& os);
1097 
1099 
1105  static OGDF_EXPORT bool writeGraphML(const GraphAttributes& A, std::ostream& os);
1106 
1108 
1114  static OGDF_EXPORT bool writeGraphML(const ClusterGraphAttributes& A, std::ostream& os);
1115 
1117 
1118 #pragma mark DOT
1119 
1124 
1127 
1134  static OGDF_EXPORT bool readDOT(Graph& G, std::istream& is);
1135 
1137 
1146  static OGDF_EXPORT bool readDOT(ClusterGraph& C, Graph& G, std::istream& is);
1147 
1149 
1158  static OGDF_EXPORT bool readDOT(GraphAttributes& A, Graph& G, std::istream& is);
1159 
1161 
1172  std::istream& is);
1173 
1175 
1181  static OGDF_EXPORT bool writeDOT(const Graph& G, std::ostream& os);
1182 
1184 
1190  static OGDF_EXPORT bool writeDOT(const ClusterGraph& C, std::ostream& os);
1191 
1193 
1199  static OGDF_EXPORT bool writeDOT(const GraphAttributes& A, std::ostream& os);
1200 
1202 
1208  static OGDF_EXPORT bool writeDOT(const ClusterGraphAttributes& A, std::ostream& os);
1209 
1211 
1212 #pragma mark GEXF
1213 
1218 
1221 
1228  static OGDF_EXPORT bool readGEXF(Graph& G, std::istream& is);
1229 
1231 
1240  static OGDF_EXPORT bool readGEXF(ClusterGraph& C, Graph& G, std::istream& is);
1241 
1243 
1252  static OGDF_EXPORT bool readGEXF(GraphAttributes& A, Graph& G, std::istream& is);
1253 
1255 
1266  std::istream& is);
1267 
1269 
1275  static OGDF_EXPORT bool writeGEXF(const Graph& G, std::ostream& os);
1276 
1278 
1284  static OGDF_EXPORT bool writeGEXF(const ClusterGraph& C, std::ostream& os);
1285 
1287 
1293  static OGDF_EXPORT bool writeGEXF(const GraphAttributes& A, std::ostream& os);
1294 
1296 
1302  static OGDF_EXPORT bool writeGEXF(const ClusterGraphAttributes& A, std::ostream& os);
1303 
1305 
1306 #pragma mark GDF
1307 
1312 
1315 
1322  static OGDF_EXPORT bool readGDF(Graph& G, std::istream& is);
1323 
1325 
1334  static OGDF_EXPORT bool readGDF(GraphAttributes& A, Graph& G, std::istream& is);
1335 
1337 
1343  static OGDF_EXPORT bool writeGDF(const Graph& G, std::ostream& os);
1344 
1346 
1352  static OGDF_EXPORT bool writeGDF(const GraphAttributes& A, std::ostream& os);
1353 
1355 
1356 #pragma mark TLP
1357 
1362 
1365 
1372  static OGDF_EXPORT bool readTLP(Graph& G, std::istream& is);
1373 
1375 
1384  static OGDF_EXPORT bool readTLP(ClusterGraph& C, Graph& G, std::istream& is);
1385 
1387 
1396  static OGDF_EXPORT bool readTLP(GraphAttributes& A, Graph& G, std::istream& is);
1397 
1399 
1410  std::istream& is);
1411 
1413 
1419  static OGDF_EXPORT bool writeTLP(const Graph& G, std::ostream& os);
1420 
1422 
1428  static OGDF_EXPORT bool writeTLP(const ClusterGraph& C, std::ostream& os);
1429 
1431 
1437  static OGDF_EXPORT bool writeTLP(const GraphAttributes& A, std::ostream& os);
1438 
1440 
1446  static OGDF_EXPORT bool writeTLP(const ClusterGraphAttributes& A, std::ostream& os);
1447 
1449 
1450 #pragma mark DL
1451 
1456 
1459 
1466  static OGDF_EXPORT bool readDL(Graph& G, std::istream& is);
1467 
1469 
1478  static OGDF_EXPORT bool readDL(GraphAttributes& A, Graph& G, std::istream& is);
1479 
1481 
1487  static OGDF_EXPORT bool writeDL(const Graph& G, std::ostream& os);
1488 
1490 
1496  static OGDF_EXPORT bool writeDL(const GraphAttributes& A, std::ostream& os);
1497 
1499 
1500 #pragma mark STP
1501 
1506 
1515  static OGDF_EXPORT bool readSTP(GraphAttributes& attr, Graph& G, List<node>& terminals,
1516  NodeArray<bool>& isTerminal, std::istream& is);
1517 
1528  static OGDF_EXPORT bool readSTP(GraphAttributes& attr, Graph& G, std::istream& is) {
1529  List<node> terminals;
1530  NodeArray<bool> isTerminal;
1531  return readSTP(attr, G, terminals, isTerminal, is);
1532  }
1533 
1541  static OGDF_EXPORT bool readSTP(Graph& G, std::istream& is) {
1542  GraphAttributes attr(G);
1543  return readSTP(attr, G, is);
1544  }
1545 
1559  template<typename T>
1560  static bool readSTP(EdgeWeightedGraph<T>& wG, List<node>& terminals,
1561  NodeArray<bool>& isTerminal, std::istream& is) {
1562  wG.clear();
1563  GraphAttributes attr(wG, getEdgeWeightFlag<T>());
1564  bool res = readSTP(attr, wG, terminals, isTerminal, is);
1565  for (edge e : wG.edges) {
1566  wG.setWeight(e, getEdgeWeightAttribute<T>(attr, e));
1567  }
1568  return res;
1569  }
1570 
1588  static OGDF_EXPORT bool writeSTP(const GraphAttributes& attr, const List<node>& terminals,
1589  std::ostream& os, const string& comments = "");
1590 
1603  template<typename T>
1604  static bool writeSTP(const EdgeWeightedGraph<T>& wG, const List<node>& terminals,
1605  std::ostream& os, const string& comments = "") {
1606  GraphAttributes attr(wG, getEdgeWeightFlag<T>());
1607  for (edge e : wG.edges) {
1608  getEdgeWeightAttribute<T>(attr, e) = wG.weight(e);
1609  }
1610  return writeSTP(attr, terminals, os, comments);
1611  }
1612 
1614 
1615 #pragma mark DMF
1616 
1621 
1628  static OGDF_EXPORT bool readDMF(GraphAttributes& attr, Graph& graph, node& source, node& sink,
1629  std::istream& is);
1630 
1640  static OGDF_EXPORT bool readDMF(GraphAttributes& attr, Graph& graph, std::istream& is) {
1641  node sink;
1642  node source;
1643  return readDMF(attr, graph, sink, source, is);
1644  };
1645 
1658  template<typename T>
1659  static bool readDMF(Graph& graph, EdgeArray<T>& weights, node& source, node& sink,
1660  std::istream& is) {
1661  GraphAttributes attr(graph, getEdgeWeightFlag<T>());
1662  bool result = readDMF(attr, graph, source, sink, is);
1663  weights.init(graph);
1664  for (edge e : graph.edges) {
1665  weights[e] = getEdgeWeightAttribute<T>(attr, e);
1666  }
1667  return result;
1668  }
1669 
1678  static OGDF_EXPORT bool readDMF(Graph& graph, std::istream& is) {
1679  GraphAttributes attr(graph);
1680  node source;
1681  node sink;
1682  return readDMF(attr, graph, source, sink, is);
1683  }
1684 
1698  static OGDF_EXPORT bool writeDMF(const GraphAttributes& attr, const node source,
1699  const node sink, std::ostream& os);
1700 
1712  template<typename T>
1713  static bool writeDMF(const Graph& graph, const EdgeArray<T>& weights, const node source,
1714  const node sink, std::ostream& os) {
1715  GraphAttributes attr(graph, getEdgeWeightFlag<T>());
1716  for (edge e : graph.edges) {
1717  getEdgeWeightAttribute<T>(attr, e) = weights[e];
1718  }
1719  return writeDMF(attr, source, sink, os);
1720  }
1721 
1722 #pragma mark TsplibXml
1723 
1728 
1731 
1736  static OGDF_EXPORT bool readTsplibXml(Graph& G, std::istream& is);
1737 
1739 
1747  static OGDF_EXPORT bool readTsplibXml(GraphAttributes& GA, Graph& G, std::istream& is);
1749 
1751 
1756 
1759 
1767  static OGDF_EXPORT bool readEdgeListSubgraph(Graph& G, List<edge>& delEdges, std::istream& is);
1768 
1770 
1778  static OGDF_EXPORT bool writeEdgeListSubgraph(const Graph& G, const List<edge>& delEdges,
1779  std::ostream& os);
1780 
1782 
1786 
1788  static OGDF_EXPORT bool drawSVG(const GraphAttributes& A, std::ostream& os,
1789  const SVGSettings& settings);
1790 
1791  static inline bool drawSVG(const GraphAttributes& A, std::ostream& os) {
1792  // we may not use a defaulted argument settings=svgSettings here if drawSVG should be a AttrWriterFunc:
1793  // https://stackoverflow.com/a/2225426/805569
1794  return drawSVG(A, os, svgSettings);
1795  }
1796 
1797  static inline bool drawSVG(const GraphAttributes& A, const string& filename,
1798  const SVGSettings& settings = svgSettings) {
1799  std::ofstream os(filename);
1800  return os.good() && drawSVG(A, os, settings);
1801  }
1802 
1803  static OGDF_EXPORT bool drawSVG(const ClusterGraphAttributes& A, std::ostream& os,
1804  const SVGSettings& settings);
1805 
1806  static inline bool drawSVG(const ClusterGraphAttributes& A, std::ostream& os) {
1807  return drawSVG(A, os, svgSettings);
1808  }
1809 
1810  static inline bool drawSVG(const ClusterGraphAttributes& A, const string& filename,
1811  const SVGSettings& settings = svgSettings) {
1812  std::ofstream os(filename);
1813  return os.good() && drawSVG(A, os, settings);
1814  }
1815 
1823  static OGDF_EXPORT bool drawTikz(const GraphAttributes& A, std::ostream& os);
1824 
1832  static OGDF_EXPORT bool drawTikz(const ClusterGraphAttributes& A, std::ostream& os);
1833 
1835 
1840 
1843  static char indentChar() { return s_indentChar; }
1844 
1846  static int indentWidth() { return s_indentWidth; }
1847 
1849 
1852  static void setIndentChar(char c) {
1853  OGDF_ASSERT(isspace((int)c));
1854  s_indentChar = c;
1855  }
1856 
1858 
1862  static void setIndentWidth(int w) {
1863  if (w >= 0) {
1864  s_indentWidth = w;
1865  }
1866  }
1867 
1869  static OGDF_EXPORT std::ostream& indent(std::ostream& os, int depth);
1870 
1874 
1877  static OGDF_EXPORT bool setColorValue(int value, std::function<void(uint8_t)> setFunction) {
1878  if (value < 0 || value > 255) {
1879  GraphIO::logger.lout() << "Error: color value is not between 0 and 255." << std::endl;
1880  return false;
1881  }
1882  setFunction(static_cast<uint8_t>(value));
1883  return true;
1884  }
1885 
1887 
1890  template<typename T, typename std::enable_if<std::is_integral<T>::value, bool>::type = 0>
1891  static long getEdgeWeightFlag() {
1893  }
1894 
1896 
1899  template<typename T, typename std::enable_if<std::is_floating_point<T>::value, bool>::type = 0>
1900  static long getEdgeWeightFlag() {
1902  }
1903 
1905 
1910  template<typename T, typename std::enable_if<std::is_integral<T>::value, bool>::type = 0>
1912  return attr.intWeight(e);
1913  }
1914 
1916 
1921  template<typename T, typename std::enable_if<std::is_floating_point<T>::value, bool>::type = 0>
1922  static double& getEdgeWeightAttribute(GraphAttributes& attr, edge e) {
1923  return attr.doubleWeight(e);
1924  }
1925 
1927 
1929 
1930 private:
1933 };
1934 
1935 }
ogdf::GraphAttributes::edgeIntWeight
static const long edgeIntWeight
Corresponds to edge attribute intWeight(edge).
Definition: GraphAttributes.h:119
ogdf::GraphIO::ClusterAttrWriterFunc
bool(*)(const ClusterGraphAttributes &, std::ostream &) ClusterAttrWriterFunc
Type of cluster graph attributes writer functions working on streams.
Definition: GraphIO.h:77
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:66
ogdf::GraphIO::readSTP
static bool readSTP(Graph &G, std::istream &is)
Reads a graph in SteinLib format from std::istream is.
Definition: GraphIO.h:1541
ogdf::GraphIO::readGraph6
static bool readGraph6(Graph &G, std::istream &is, bool forceHeader=false)
Reads graph G in Graph6 format from input stream is.
ogdf::GraphIO::ClusterReaderFunc
bool(*)(ClusterGraph &, Graph &, std::istream &) ClusterReaderFunc
Type of cluster graph reader functions working on streams.
Definition: GraphIO.h:67
ogdf::GraphIO::readChaco
static bool readChaco(Graph &G, std::istream &is)
Reads graph G in Chaco format from input stream is.
ogdf::GraphIO::getEdgeWeightAttribute
static int & getEdgeWeightAttribute(GraphAttributes &attr, edge e)
Returns a reference to the intWeight()-value of attr for e.
Definition: GraphIO.h:1911
ogdf::GraphIO::readSTP
static bool readSTP(GraphAttributes &attr, Graph &G, List< node > &terminals, NodeArray< bool > &isTerminal, std::istream &is)
Reads a graph in SteinLib format from std::istream is.
ogdf::GraphIO::indentChar
static char indentChar()
Returns the currently used indentation character.
Definition: GraphIO.h:1843
ogdf::GraphIO::write
static bool write(const Graph &G, const string &filename, WriterFunc writer=nullptr)
Writes graph G to a file with name filename and infers the format to use from the file's extension.
exceptions.h
Definition of exception classes.
ogdf::GraphIO::SVGSettings::m_width
string m_width
Definition: GraphIO.h:123
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:54
ogdf::GraphIO::SVGSettings::fontFamily
const string & fontFamily() const
Returns the default font family.
Definition: GraphIO.h:145
ogdf::EdgeWeightedGraph::weight
T weight(const edge e) const
Definition: EdgeWeightedGraph.h:58
ogdf::GraphIO::FileType::extensions
std::vector< std::string > extensions
Definition: GraphIO.h:80
ogdf::GraphIO::writeGML
static bool writeGML(const Graph &G, std::ostream &os)
Writes graph G in GML format to output stream os.
ogdf::GraphIO::drawSVG
static bool drawSVG(const GraphAttributes &A, std::ostream &os, const SVGSettings &settings)
ogdf::GraphIO::SVGSettings::m_curviness
double m_curviness
Definition: GraphIO.h:119
ogdf::GraphIO::getFileType
static const FileType * getFileType(const string &filename)
ogdf::GraphIO::SVGSettings::m_fontSize
int m_fontSize
Definition: GraphIO.h:118
ogdf::GraphIO::FileType::auto_cluster_attr_reader_func
ClusterAttrReaderFunc auto_cluster_attr_reader_func
Definition: GraphIO.h:91
ogdf::GraphIO::drawSVG
static bool drawSVG(const GraphAttributes &A, std::ostream &os)
Definition: GraphIO.h:1791
ogdf::whaType::A
@ A
ogdf::GraphIO::svgSettings
static SVGSettings svgSettings
Definition: GraphIO.h:1928
ogdf::GraphIO::SVGSettings::curviness
void curviness(double value)
Sets the curviness of all edges (value ranges from 0 to 1).
Definition: GraphIO.h:157
ogdf::GraphIO::setIndentWidth
static void setIndentWidth(int w)
Sets the indentation width to w.
Definition: GraphIO.h:1862
ogdf::GraphIO::drawSVG
static bool drawSVG(const ClusterGraphAttributes &A, const string &filename, const SVGSettings &settings=svgSettings)
Definition: GraphIO.h:1810
ogdf::GraphIO::writeLEDA
static bool writeLEDA(const Graph &G, std::ostream &os)
Writes graph G in LEDA graph format to output stream os.
ogdf::GraphIO::FileType::replaceAutoReaders
FileType & replaceAutoReaders(ReaderFunc readerFunc=nullptr, AttrReaderFunc attrReaderFunc=nullptr, ClusterReaderFunc clusterReaderFunc=nullptr, ClusterAttrReaderFunc clusterAttrReaderFunc=nullptr)
ogdf::GraphIO::readRudy
static bool readRudy(GraphAttributes &A, Graph &G, std::istream &is)
Reads graph G with edge weights stored in A in Rudy format from input stream is.
ogdf::GraphIO::WriterFunc
bool(*)(const Graph &, std::ostream &) WriterFunc
Type of simple graph writer functions working on streams.
Definition: GraphIO.h:58
ogdf::GraphIO::SVGSettings::fontSize
int fontSize() const
Returns the default font size (font height in pixels).
Definition: GraphIO.h:139
ogdf::GraphIO::readGML
static bool readGML(Graph &G, std::istream &is)
Reads graph G in GML format from input stream is.
ogdf::GraphIO::readSTP
static bool readSTP(GraphAttributes &attr, Graph &G, std::istream &is)
Reads a graph in SteinLib format from std::istream is.
Definition: GraphIO.h:1528
ogdf::GraphIO::AttrWriterFunc
bool(*)(const GraphAttributes &, std::ostream &) AttrWriterFunc
Type of simple graph attributes writer functions working on streams.
Definition: GraphIO.h:64
ogdf::GraphIO::FileType::reader_func
ReaderFunc reader_func
Definition: GraphIO.h:81
ogdf::GraphIO::readRudy
static bool readRudy(Graph &G, std::istream &is)
Reads graph G in Rudy format from input stream is.
Definition: GraphIO.h:912
ogdf::GraphIO::FileType::auto_reader_func
ReaderFunc auto_reader_func
Definition: GraphIO.h:82
ogdf::GraphIO::writePMDissGraph
static bool writePMDissGraph(const Graph &G, std::ostream &os)
Writes graph G in a simple format as used in Petra Mutzel's thesis to output stream os.
ogdf::GraphIO::SVGSettings::margin
double margin() const
Returns the size of the margin around the drawing.
Definition: GraphIO.h:133
ogdf::GraphIO::writeDMF
static bool writeDMF(const Graph &graph, const EdgeArray< T > &weights, const node source, const node sink, std::ostream &os)
Writes a maximum flow problem instance to a DIMACS maximum flow file.
Definition: GraphIO.h:1713
ogdf::GraphIO::FileType::FileType
FileType(std::vector< std::string > extensions, ReaderFunc readerFunc=nullptr, WriterFunc writerFunc=nullptr, AttrReaderFunc attrReaderFunc=nullptr, AttrWriterFunc attrWriterFunc=nullptr, ClusterReaderFunc clusterReaderFunc=nullptr, ClusterWriterFunc clusterWriterFunc=nullptr, ClusterAttrReaderFunc clusterAttrReaderFunc=nullptr, ClusterAttrWriterFunc clusterAttrWriterFunc=nullptr)
ogdf::GraphIO::getFileTypeMap
static const std::unordered_map< string, const FileType * > & getFileTypeMap()
ogdf::GraphIO::writeSTP
static bool writeSTP(const EdgeWeightedGraph< T > &wG, const List< node > &terminals, std::ostream &os, const string &comments="")
Writes an Steiner problem instance to an STP file.
Definition: GraphIO.h:1604
ogdf::GraphIO::FileType::cluster_attr_writer_func
ClusterAttrWriterFunc cluster_attr_writer_func
Definition: GraphIO.h:92
ogdf::GraphIO::readYGraph
static bool readYGraph(Graph &G, std::istream &is)
Reads graph G in Y-graph format from input stream is.
ogdf::GraphIO::readGraphML
static bool readGraphML(Graph &G, std::istream &is)
Reads graph G in GraphML format from input stream is.
ogdf::GraphIO::readPMDissGraph
static bool readPMDissGraph(Graph &G, std::istream &is)
Reads graph G in a simple format as used in Petra Mutzel's thesis from input stream is.
ogdf::GraphIO::SVGSettings::fontColor
void fontColor(const string &fc)
Sets the default font color to fc.
Definition: GraphIO.h:171
ogdf::GraphIO::logger
static Logger logger
Definition: GraphIO.h:52
ogdf::GraphIO::ClusterWriterFunc
bool(*)(const ClusterGraph &, std::ostream &) ClusterWriterFunc
Type of cluster graph writer functions working on streams.
Definition: GraphIO.h:70
ogdf::GraphIO::SVGSettings::width
void width(const string &width)
Sets the width.
Definition: GraphIO.h:180
ogdf::GraphIO::readMatrixMarket
static bool readMatrixMarket(Graph &G, std::istream &inStream)
Reads graph G in Matrix Market exchange format from stream inStream.
ogdf::GraphIO::s_indentChar
static char s_indentChar
Character used for indentation.
Definition: GraphIO.h:1931
ogdf::GraphIO::FileType
Definition: GraphIO.h:79
ogdf::GraphIO::writeDMF
static bool writeDMF(const GraphAttributes &attr, const node source, const node sink, std::ostream &os)
Writes a maximum flow problem instance to a DIMACS maximum flow file.
ogdf::GraphIO::readRome
static bool readRome(Graph &G, std::istream &is)
Reads graph G in Rome-Lib format from input stream is.
ogdf::GraphIO::readDL
static bool readDL(Graph &G, std::istream &is)
Reads graph G in DL format from input stream is.
ogdf::GraphIO::writeChallengeGraph
static bool writeChallengeGraph(const Graph &G, const GridLayout &gl, std::ostream &os)
Writes graph G with grid layout gl in GD-Challenge-format to output stream os.
ogdf::Graph::clear
virtual void clear()
Removes all nodes and all edges from the graph.
ogdf::ClusterGraphAttributes
Stores additional attributes of a clustered graph (like layout information).
Definition: ClusterGraphAttributes.h:46
ogdf::GraphIO::writeGDF
static bool writeGDF(const Graph &G, std::ostream &os)
Writes graph G in GDF format to output stream os.
ogdf::GraphIO::FileType::attr_reader_func
AttrReaderFunc attr_reader_func
Definition: GraphIO.h:84
ogdf::GraphIO::setColorValue
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:1877
ogdf::GraphIO::writeDOT
static bool writeDOT(const Graph &G, std::ostream &os)
Writes graph G in DOT format to output stream os.
ogdf::GraphIO::SVGSettings::height
const string & height() const
Returns the default height.
Definition: GraphIO.h:151
ogdf::GraphIO::readDOT
static bool readDOT(Graph &G, std::istream &is)
Reads graph G in DOT format from input stream is.
ogdf::GraphIO::readDMF
static bool readDMF(GraphAttributes &attr, Graph &graph, std::istream &is)
Reads a maximum flow instance in DIMACS format.
Definition: GraphIO.h:1640
ogdf::GraphIO::SVGSettings
Condensed settings for drawing SVGs.
Definition: GraphIO.h:116
ogdf::GraphIO::readDigraph6
static bool readDigraph6(Graph &G, std::istream &is, bool forceHeader=false)
Reads graph G in Digraph6 format from input stream is.
ogdf::GraphIO::ClusterAttrReaderFunc
bool(*)(ClusterGraphAttributes &, ClusterGraph &, Graph &, std::istream &) ClusterAttrReaderFunc
Type of cluster graph attributes reader functions working on streams.
Definition: GraphIO.h:74
ogdf::GraphIO
Utility class providing graph I/O in various exchange formats.
Definition: GraphIO.h:50
ogdf::GraphIO::readEdgeListSubgraph
static bool readEdgeListSubgraph(Graph &G, List< edge > &delEdges, std::istream &is)
Reads graph G with subgraph defined by delEdges from stream is.
backward::Color::type
type
Definition: backward.hpp:1716
ogdf::GraphIO::indentWidth
static int indentWidth()
Returns the currently used indentation width.
Definition: GraphIO.h:1846
ogdf::EdgeWeightedGraph
Definition: EdgeWeightedGraph.h:39
ogdf::GraphIO::writeGEXF
static bool writeGEXF(const Graph &G, std::ostream &os)
Writes graph G in GEXF format to output stream os.
ogdf::GraphIO::readDMF
static bool readDMF(GraphAttributes &attr, Graph &graph, node &source, node &sink, std::istream &is)
Reads a maximum flow instance in DIMACS format.
ogdf::GraphIO::FileType::cluster_writer_func
ClusterWriterFunc cluster_writer_func
Definition: GraphIO.h:89
ogdf::GraphIO::writeSTP
static bool writeSTP(const GraphAttributes &attr, const List< node > &terminals, std::ostream &os, const string &comments="")
Writes an Steiner problem instance to an STP file.
ogdf::GraphIO::getEdgeWeightFlag
static long getEdgeWeightFlag()
Returns GraphAttributes::edgeIntWeight.
Definition: GraphIO.h:1891
ogdf::GraphIO::indent
static std::ostream & indent(std::ostream &os, int depth)
Prints indentation for indentation depth to output stream os and returns os.
ogdf::GraphIO::SVGSettings::margin
void margin(double m)
Sets the size of the margin around the drawing to m.
Definition: GraphIO.h:154
ogdf::GraphIO::AttrReaderFunc
bool(*)(GraphAttributes &, Graph &, std::istream &) AttrReaderFunc
Type of simple graph attributes reader functions working on streams.
Definition: GraphIO.h:61
ogdf::GraphIO::readDMF
static bool readDMF(Graph &graph, EdgeArray< T > &weights, node &source, node &sink, std::istream &is)
Reads a maximum flow instance in DIMACS format.
Definition: GraphIO.h:1659
ogdf::List
Doubly linked lists (maintaining the length of the list).
Definition: List.h:42
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
ogdf::GraphIO::FileType::attr_writer_func
AttrWriterFunc attr_writer_func
Definition: GraphIO.h:86
ogdf::GraphIO::readChallengeGraph
static bool readChallengeGraph(Graph &G, GridLayout &gl, std::istream &is)
Reads graph G with grid layout gl in GD-Challenge-format from input stream is.
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
ogdf::GraphIO::SVGSettings::width
const string & width() const
Returns the default width.
Definition: GraphIO.h:148
ogdf::GraphIO::readLEDA
static bool readLEDA(Graph &G, std::istream &is)
Reads graph G in LEDA graph format from input stream is.
ogdf::GraphIO::writeRudy
static bool writeRudy(const GraphAttributes &A, std::ostream &os)
Writes graph with edge weights stored in A in Rudy format to output stream os.
ogdf::GraphIO::writeDL
static bool writeDL(const Graph &G, std::ostream &os)
Writes graph G in DL format to output stream os.
ogdf::GraphIO::writeGraph6
static bool writeGraph6(const Graph &G, std::ostream &os)
Writes graph G in Graph6 format to output stream os.
ogdf::GraphIO::writeChaco
static bool writeChaco(const Graph &G, std::ostream &os)
Writes graph G in Chaco format to output stream os.
ogdf::GraphIO::readDMF
static bool readDMF(Graph &graph, std::istream &is)
Reads a maximum flow instance in DIMACS format.
Definition: GraphIO.h:1678
ogdf::GraphIO::getEdgeWeightAttribute
static double & getEdgeWeightAttribute(GraphAttributes &attr, edge e)
Returns a reference to the doubleWeight()-value of attr for e.
Definition: GraphIO.h:1922
ogdf::GraphIO::writeGraphML
static bool writeGraphML(const Graph &G, std::ostream &os)
Writes graph G in GraphML format to output stream os.
ogdf::Graph::edges
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Definition: Graph_d.h:927
ogdf::GraphIO::readBENCH
static bool readBENCH(Graph &G, List< node > &hypernodes, List< edge > *shell, std::istream &is)
Reads a hypergraph (as point-based expansion) in BENCH format from input stream is.
ogdf::GraphIO::SVGSettings::bezierInterpolation
void bezierInterpolation(bool enable)
Enables or disables Bézier-interpolation.
Definition: GraphIO.h:165
ogdf::GraphIO::drawSVG
static bool drawSVG(const GraphAttributes &A, const string &filename, const SVGSettings &settings=svgSettings)
Definition: GraphIO.h:1797
ogdf::GraphIO::FileType::auto_cluster_reader_func
ClusterReaderFunc auto_cluster_reader_func
Definition: GraphIO.h:88
EdgeWeightedGraph.h
Declaration of class EdgeWeightedGraph.
ogdf::GraphIO::SVGSettings::fontSize
void fontSize(int fs)
Sets the default font size (font height in pixels) to fs.
Definition: GraphIO.h:168
ogdf::GraphIO::drawSVG
static bool drawSVG(const ClusterGraphAttributes &A, std::ostream &os)
Definition: GraphIO.h:1806
ogdf::GraphIO::readGDF
static bool readGDF(Graph &G, std::istream &is)
Reads graph G in GDF format from input stream is.
ogdf::GraphIO::SVGSettings::fontColor
const string & fontColor() const
Returns the default font color.
Definition: GraphIO.h:142
ogdf::GraphIO::SVGSettings::m_fontColor
string m_fontColor
Definition: GraphIO.h:121
ogdf::GraphIO::SVGSettings::m_height
string m_height
Definition: GraphIO.h:124
ogdf::GraphIO::readGEXF
static bool readGEXF(Graph &G, std::istream &is)
Reads graph G in GEXF format from input stream is.
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::GraphIO::read
static bool read(Graph &G, const string &filename, ReaderFunc reader=nullptr)
Reads graph G from a file with name filename and infers the used format from the file's extension.
ogdf::GraphIO::FileType::cluster_reader_func
ClusterReaderFunc cluster_reader_func
Definition: GraphIO.h:87
ogdf::GraphIO::writeTLP
static bool writeTLP(const Graph &G, std::ostream &os)
Writes graph G in TLP format to output stream os.
ogdf::GraphIO::FileType::writer_func
WriterFunc writer_func
Definition: GraphIO.h:83
ogdf::GraphIO::drawTikz
static bool drawTikz(const GraphAttributes &A, std::ostream &os)
Draws a graph from its attributes in LaTeX+TikZ format.
ogdf::GraphIO::writeDigraph6
static bool writeDigraph6(const Graph &G, std::ostream &os)
Writes graph G in Digraph6 format to output stream os.
ClusterGraphAttributes.h
Declares ClusterGraphAttributes, an extension of class GraphAttributes, to store clustergraph layout ...
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:356
ogdf::GraphIO::ReaderFunc
bool(*)(Graph &, std::istream &) ReaderFunc
Type of simple graph reader functions working on streams.
Definition: GraphIO.h:55
ogdf::GraphIO::readTsplibXml
static bool readTsplibXml(Graph &G, std::istream &is)
Reads graph G in TsplibXml format from input stream is.
ogdf::GraphIO::SVGSettings::curviness
double curviness() const
Returns the curviness of the edges (value ranges from 0 to 1).
Definition: GraphIO.h:136
ogdf::RegisteredArray< GraphRegistry< EdgeElement >, Value, WithDefault, Graph >::init
void init(const Graph *base=nullptr)
Reinitializes the array. Associates the array with the matching registry of base.
Definition: RegisteredArray.h:849
ogdf::GraphIO::writeRome
static bool writeRome(const Graph &G, std::ostream &os)
Writes graph G in Rome-Lib format to output stream os.
ogdf::GridLayout
Representation of a graph's grid layout.
Definition: GridLayout.h:46
ogdf::GraphIO::s_indentWidth
static int s_indentWidth
Number of indent characters used for indentation.
Definition: GraphIO.h:1932
ogdf::GraphIO::SVGSettings::bezierInterpolation
bool bezierInterpolation() const
Returns whether Bézier-interpolation for curved edges is enabled.
Definition: GraphIO.h:130
ogdf::GraphAttributes::intWeight
int intWeight(edge e) const
Returns the (integer) weight of edge e.
Definition: GraphAttributes.h:768
ogdf::GraphIO::setIndentChar
static void setIndentChar(char c)
Sets the indentation character to c.
Definition: GraphIO.h:1852
ogdf::GraphAttributes::edgeDoubleWeight
static const long edgeDoubleWeight
Corresponds to edge attribute doubleWeight(edge).
Definition: GraphAttributes.h:122
ogdf::GraphIO::FILE_TYPES
static const std::vector< FileType > FILE_TYPES
Definition: GraphIO.h:108
ogdf::GraphIO::FileType::auto_attr_reader_func
AttrReaderFunc auto_attr_reader_func
Definition: GraphIO.h:85
ogdf::GraphAttributes::doubleWeight
double doubleWeight(edge e) const
Returns the (real number) weight of edge e.
Definition: GraphAttributes.h:786
ogdf::GraphIO::writeEdgeListSubgraph
static bool writeEdgeListSubgraph(const Graph &G, const List< edge > &delEdges, std::ostream &os)
Writes graph G with subgraph defined by delEdges to stream os.
ogdf::GraphIO::SVGSettings::m_fontFamily
string m_fontFamily
Definition: GraphIO.h:122
ogdf::Logger
Centralized global and local logging facility working on streams like std::cout.
Definition: Logger.h:100
ogdf::EdgeWeightedGraph::setWeight
void setWeight(const edge e, T weight)
Definition: EdgeWeightedGraph.h:62
ogdf::GraphIO::FILE_TYPE_MAP
static std::unordered_map< string, const FileType * > FILE_TYPE_MAP
Definition: GraphIO.h:109
ogdf::GraphIO::SVGSettings::fontFamily
void fontFamily(const string &fm)
Sets the default font family to fm.
Definition: GraphIO.h:174
ogdf::GraphIO::readSTP
static bool readSTP(EdgeWeightedGraph< T > &wG, List< node > &terminals, NodeArray< bool > &isTerminal, std::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:1560
ogdf::GraphIO::SVGSettings::m_margin
double m_margin
Definition: GraphIO.h:117
ogdf::GraphIO::readSparse6
static bool readSparse6(Graph &G, std::istream &is, bool forceHeader=false)
Reads graph G in Sparse6 format from input stream is.
ogdf::ClusterGraph
Representation of clustered graphs.
Definition: ClusterGraph.h:339
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::GraphIO::readTLP
static bool readTLP(Graph &G, std::istream &is)
Reads graph G in TLP format from input stream is.
GridLayout.h
Declaration of class GridLayout.
ogdf::GraphIO::readPLA
static bool readPLA(Graph &G, List< node > &hypernodes, List< edge > *shell, std::istream &is)
Reads a hypergraph (as point-based expansion) in PLA format from input stream is.
ogdf::GraphIO::SVGSettings::height
void height(const string &height)
Sets the height.
Definition: GraphIO.h:186
ogdf::GraphIO::FileType::cluster_attr_reader_func
ClusterAttrReaderFunc cluster_attr_reader_func
Definition: GraphIO.h:90
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:709
ogdf::GraphIO::SVGSettings::m_bezierInterpolation
bool m_bezierInterpolation
Definition: GraphIO.h:120
ogdf::Logger::lout
std::ostream & lout(Level level=Level::Default, bool indent=true) const
stream for logging-output (local)
Definition: Logger.h:158
ogdf::GraphIO::writeSparse6
static bool writeSparse6(const Graph &G, std::ostream &os)
Writes graph G in Sparse6 format to output stream os.