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/Graph.h>
37 #include <ogdf/basic/GraphList.h>
38 #include <ogdf/basic/List.h>
39 #include <ogdf/basic/Logger.h>
40 #include <ogdf/basic/basic.h>
43 
44 #include <cctype>
45 #include <cstdint>
46 #include <fstream>
47 #include <functional>
48 #include <string>
49 #include <type_traits>
50 #include <unordered_map>
51 #include <vector>
52 
53 namespace ogdf {
54 class GridLayout;
55 template<typename T>
57 
59 
62 class GraphIO {
63 public:
65 
67  using ReaderFunc = bool (*)(Graph&, std::istream&);
68 
70  using WriterFunc = bool (*)(const Graph&, std::ostream&);
71 
73  using AttrReaderFunc = bool (*)(GraphAttributes&, Graph&, std::istream&);
74 
76  using AttrWriterFunc = bool (*)(const GraphAttributes&, std::ostream&);
77 
79  using ClusterReaderFunc = bool (*)(ClusterGraph&, Graph&, std::istream&);
80 
82  using ClusterWriterFunc = bool (*)(const ClusterGraph&, std::ostream&);
83 
86  std::istream&);
87 
89  using ClusterAttrWriterFunc = bool (*)(const ClusterGraphAttributes&, std::ostream&);
90 
91  struct FileType {
92  std::vector<std::string> extensions;
105 
106  explicit FileType(std::vector<std::string> extensions, ReaderFunc readerFunc = nullptr,
107  WriterFunc writerFunc = nullptr, AttrReaderFunc attrReaderFunc = nullptr,
108  AttrWriterFunc attrWriterFunc = nullptr,
109  ClusterReaderFunc clusterReaderFunc = nullptr,
110  ClusterWriterFunc clusterWriterFunc = nullptr,
111  ClusterAttrReaderFunc clusterAttrReaderFunc = nullptr,
112  ClusterAttrWriterFunc clusterAttrWriterFunc = nullptr);
113 
114  FileType& replaceAutoReaders(ReaderFunc readerFunc = nullptr,
115  AttrReaderFunc attrReaderFunc = nullptr,
116  ClusterReaderFunc clusterReaderFunc = nullptr,
117  ClusterAttrReaderFunc clusterAttrReaderFunc = nullptr);
118  };
119 
120  static const OGDF_EXPORT std::vector<FileType> FILE_TYPES;
121  static OGDF_EXPORT std::unordered_map<string, const FileType*> FILE_TYPE_MAP;
122 
123  static OGDF_EXPORT const std::unordered_map<string, const FileType*>& getFileTypeMap();
124 
125  static OGDF_EXPORT const FileType* getFileType(const string& filename);
126 
129  double m_margin;
131  double m_curviness;
133  string m_fontColor;
134  string m_fontFamily;
135  string m_width;
136  string m_height;
137 
138  public:
139  SVGSettings();
140 
142  bool bezierInterpolation() const { return m_bezierInterpolation; }
143 
145  double margin() const { return m_margin; }
146 
148  double curviness() const { return m_curviness; }
149 
151  int fontSize() const { return m_fontSize; }
152 
154  const string& fontColor() const { return m_fontColor; }
155 
157  const string& fontFamily() const { return m_fontFamily; }
158 
160  const string& width() const { return m_width; }
161 
163  const string& height() const { return m_height; }
164 
166  void margin(double m) { m_margin = m; }
167 
169  void curviness(double value) {
170  OGDF_ASSERT(value >= 0);
171  OGDF_ASSERT(value <= 1);
172 
173  m_curviness = value;
174  }
175 
177  void bezierInterpolation(bool enable) { m_bezierInterpolation = enable; }
178 
180  void fontSize(int fs) { m_fontSize = fs; }
181 
183  void fontColor(const string& fc) { m_fontColor = fc; }
184 
186  void fontFamily(const string& fm) { m_fontFamily = fm; }
187 
189 
192  void width(const string& width) { m_width = width; }
193 
195 
198  void height(const string& height) { m_height = height; }
199  };
200 
319 
330  static OGDF_EXPORT bool read(Graph& G, const string& filename, ReaderFunc reader = nullptr);
331 
342  static OGDF_EXPORT bool read(GraphAttributes& GA, Graph& G, const string& filename,
343  AttrReaderFunc reader = nullptr);
344 
355  static OGDF_EXPORT bool read(ClusterGraph& CG, Graph& G, const string& filename,
356  ClusterReaderFunc reader = nullptr);
357 
371  static OGDF_EXPORT bool read(ClusterGraphAttributes& GA, ClusterGraph& CG, Graph& G,
372  const string& filename, ClusterAttrReaderFunc reader = nullptr);
373 
383  static OGDF_EXPORT bool read(Graph& G, std::istream& is);
384 
395  static OGDF_EXPORT bool read(GraphAttributes& GA, Graph& G, std::istream& is);
396 
407  static OGDF_EXPORT bool read(ClusterGraph& CG, Graph& G, std::istream& is);
408 
422  static OGDF_EXPORT bool read(ClusterGraphAttributes& GA, ClusterGraph& CG, Graph& G,
423  std::istream& is);
424 
433  static OGDF_EXPORT bool write(const Graph& G, const string& filename,
434  WriterFunc writer = nullptr);
435 
444  static OGDF_EXPORT bool write(const GraphAttributes& GA, const string& filename,
445  AttrWriterFunc writer = nullptr);
446 
455  static OGDF_EXPORT bool write(const ClusterGraph& CG, const string& filename,
456  ClusterWriterFunc writer = nullptr);
457 
468  static OGDF_EXPORT bool write(const ClusterGraphAttributes& GA, const string& filename,
469  ClusterAttrWriterFunc writer = nullptr);
470 
472 
473 #pragma mark GML
474 
479 
482 
494  static OGDF_EXPORT bool readGML(Graph& G, std::istream& is);
495 
497 
509  static OGDF_EXPORT bool writeGML(const Graph& G, std::ostream& os);
510 
512 
521  static OGDF_EXPORT bool readGML(ClusterGraph& C, Graph& G, std::istream& is);
522 
524 
531  static OGDF_EXPORT bool writeGML(const ClusterGraph& C, std::ostream& os);
532 
534 
545  std::istream& is);
546 
548 
555  static OGDF_EXPORT bool writeGML(const ClusterGraphAttributes& A, std::ostream& os);
556 
558 
567  static OGDF_EXPORT bool readGML(GraphAttributes& A, Graph& G, std::istream& is);
568 
570 
577  static OGDF_EXPORT bool writeGML(const GraphAttributes& A, std::ostream& os);
578 
580 
581 #pragma mark Rome
582 
587 
590 
603  static OGDF_EXPORT bool readRome(Graph& G, std::istream& is);
604 
606 
613  static OGDF_EXPORT bool writeRome(const Graph& G, std::ostream& os);
614 
616 
617 #pragma mark LEDA
618 
623 
626 
639  static OGDF_EXPORT bool readLEDA(Graph& G, std::istream& is);
640 
642 
655  static OGDF_EXPORT bool writeLEDA(const Graph& G, std::ostream& os);
656 
658 
659 #pragma mark Chaco
660 
665 
668 
681  static OGDF_EXPORT bool readChaco(Graph& G, std::istream& is);
682 
684 
697  static OGDF_EXPORT bool writeChaco(const Graph& G, std::ostream& os);
698 
700 
701 #pragma mark PMDissGraph
702 
707 
710 
725  static OGDF_EXPORT bool readPMDissGraph(Graph& G, std::istream& is);
726 
728 
743  static OGDF_EXPORT bool writePMDissGraph(const Graph& G, std::ostream& os);
744 
746 
747 #pragma mark YGraph
748 
753 
756 
776  static OGDF_EXPORT bool readYGraph(Graph& G, std::istream& is);
777 
779 
780 #pragma mark Graph6
781 
789 
792 
800  static OGDF_EXPORT bool readGraph6(Graph& G, std::istream& is, bool forceHeader = false);
801 
803 
810  static OGDF_EXPORT bool writeGraph6(const Graph& G, std::ostream& os);
811 
813 
814 #pragma mark Digraph6
815 
822 
825 
833  static OGDF_EXPORT bool readDigraph6(Graph& G, std::istream& is, bool forceHeader = false);
834 
836 
843  static OGDF_EXPORT bool writeDigraph6(const Graph& G, std::ostream& os);
844 
846 
847 #pragma mark Sparse6
848 
855 
858 
866  static OGDF_EXPORT bool readSparse6(Graph& G, std::istream& is, bool forceHeader = false);
867 
869 
876  static OGDF_EXPORT bool writeSparse6(const Graph& G, std::ostream& os);
877 
879 
880 #pragma mark MatrixMarket
881 
886 
889 
894  static OGDF_EXPORT bool readMatrixMarket(Graph& G, std::istream& inStream);
895 
897 
898 #pragma mark Rudy
899 
902 
905 
914  static OGDF_EXPORT bool readRudy(GraphAttributes& A, Graph& G, std::istream& is);
915 
917 
924  static OGDF_EXPORT bool readRudy(Graph& G, std::istream& is) {
926  return readRudy(A, G, is);
927  }
928 
930 
938  static OGDF_EXPORT bool writeRudy(const GraphAttributes& A, std::ostream& os);
939 
941 
942 #pragma mark BENCH
943 
946 
949 
966  static OGDF_EXPORT bool readBENCH(Graph& G, List<node>& hypernodes, List<edge>* shell,
967  std::istream& is);
968 
970 
971 #pragma mark PLA
972 
975 
978 
995  static OGDF_EXPORT bool readPLA(Graph& G, List<node>& hypernodes, List<edge>* shell,
996  std::istream& is);
997 
999 
1000 #pragma mark ChallengeGraph
1001 
1007 
1010 
1019  static OGDF_EXPORT bool readChallengeGraph(Graph& G, GridLayout& gl, std::istream& is);
1020 
1022 
1031  static OGDF_EXPORT bool writeChallengeGraph(const Graph& G, const GridLayout& gl,
1032  std::ostream& os);
1033 
1035 
1036 #pragma mark GraphML
1037 
1042 
1045 
1052  static OGDF_EXPORT bool readGraphML(Graph& G, std::istream& is);
1053 
1055 
1064  static OGDF_EXPORT bool readGraphML(ClusterGraph& C, Graph& G, std::istream& is);
1065 
1067 
1076  static OGDF_EXPORT bool readGraphML(GraphAttributes& A, Graph& G, std::istream& is);
1077 
1079 
1090  std::istream& is);
1091 
1093 
1099  static OGDF_EXPORT bool writeGraphML(const Graph& G, std::ostream& os);
1100 
1102 
1108  static OGDF_EXPORT bool writeGraphML(const ClusterGraph& C, std::ostream& os);
1109 
1111 
1117  static OGDF_EXPORT bool writeGraphML(const GraphAttributes& A, std::ostream& os);
1118 
1120 
1126  static OGDF_EXPORT bool writeGraphML(const ClusterGraphAttributes& A, std::ostream& os);
1127 
1129 
1130 #pragma mark DOT
1131 
1136 
1139 
1146  static OGDF_EXPORT bool readDOT(Graph& G, std::istream& is);
1147 
1149 
1158  static OGDF_EXPORT bool readDOT(ClusterGraph& C, Graph& G, std::istream& is);
1159 
1161 
1170  static OGDF_EXPORT bool readDOT(GraphAttributes& A, Graph& G, std::istream& is);
1171 
1173 
1184  std::istream& is);
1185 
1187 
1193  static OGDF_EXPORT bool writeDOT(const Graph& G, std::ostream& os);
1194 
1196 
1202  static OGDF_EXPORT bool writeDOT(const ClusterGraph& C, std::ostream& os);
1203 
1205 
1211  static OGDF_EXPORT bool writeDOT(const GraphAttributes& A, std::ostream& os);
1212 
1214 
1220  static OGDF_EXPORT bool writeDOT(const ClusterGraphAttributes& A, std::ostream& os);
1221 
1223 
1224 #pragma mark GEXF
1225 
1230 
1233 
1240  static OGDF_EXPORT bool readGEXF(Graph& G, std::istream& is);
1241 
1243 
1252  static OGDF_EXPORT bool readGEXF(ClusterGraph& C, Graph& G, std::istream& is);
1253 
1255 
1264  static OGDF_EXPORT bool readGEXF(GraphAttributes& A, Graph& G, std::istream& is);
1265 
1267 
1278  std::istream& is);
1279 
1281 
1287  static OGDF_EXPORT bool writeGEXF(const Graph& G, std::ostream& os);
1288 
1290 
1296  static OGDF_EXPORT bool writeGEXF(const ClusterGraph& C, std::ostream& os);
1297 
1299 
1305  static OGDF_EXPORT bool writeGEXF(const GraphAttributes& A, std::ostream& os);
1306 
1308 
1314  static OGDF_EXPORT bool writeGEXF(const ClusterGraphAttributes& A, std::ostream& os);
1315 
1317 
1318 #pragma mark GDF
1319 
1324 
1327 
1334  static OGDF_EXPORT bool readGDF(Graph& G, std::istream& is);
1335 
1337 
1346  static OGDF_EXPORT bool readGDF(GraphAttributes& A, Graph& G, std::istream& is);
1347 
1349 
1355  static OGDF_EXPORT bool writeGDF(const Graph& G, std::ostream& os);
1356 
1358 
1364  static OGDF_EXPORT bool writeGDF(const GraphAttributes& A, std::ostream& os);
1365 
1367 
1368 #pragma mark TLP
1369 
1374 
1377 
1384  static OGDF_EXPORT bool readTLP(Graph& G, std::istream& is);
1385 
1387 
1396  static OGDF_EXPORT bool readTLP(ClusterGraph& C, Graph& G, std::istream& is);
1397 
1399 
1408  static OGDF_EXPORT bool readTLP(GraphAttributes& A, Graph& G, std::istream& is);
1409 
1411 
1422  std::istream& is);
1423 
1425 
1431  static OGDF_EXPORT bool writeTLP(const Graph& G, std::ostream& os);
1432 
1434 
1440  static OGDF_EXPORT bool writeTLP(const ClusterGraph& C, std::ostream& os);
1441 
1443 
1449  static OGDF_EXPORT bool writeTLP(const GraphAttributes& A, std::ostream& os);
1450 
1452 
1458  static OGDF_EXPORT bool writeTLP(const ClusterGraphAttributes& A, std::ostream& os);
1459 
1461 
1462 #pragma mark DL
1463 
1468 
1471 
1478  static OGDF_EXPORT bool readDL(Graph& G, std::istream& is);
1479 
1481 
1490  static OGDF_EXPORT bool readDL(GraphAttributes& A, Graph& G, std::istream& is);
1491 
1493 
1499  static OGDF_EXPORT bool writeDL(const Graph& G, std::ostream& os);
1500 
1502 
1508  static OGDF_EXPORT bool writeDL(const GraphAttributes& A, std::ostream& os);
1509 
1511 
1512 #pragma mark STP
1513 
1518 
1527  static OGDF_EXPORT bool readSTP(GraphAttributes& attr, Graph& G, List<node>& terminals,
1528  NodeArray<bool>& isTerminal, std::istream& is);
1529 
1540  static OGDF_EXPORT bool readSTP(GraphAttributes& attr, Graph& G, std::istream& is) {
1541  List<node> terminals;
1542  NodeArray<bool> isTerminal;
1543  return readSTP(attr, G, terminals, isTerminal, is);
1544  }
1545 
1553  static OGDF_EXPORT bool readSTP(Graph& G, std::istream& is) {
1554  GraphAttributes attr(G);
1555  return readSTP(attr, G, is);
1556  }
1557 
1571  template<typename T>
1572  static bool readSTP(EdgeWeightedGraph<T>& wG, List<node>& terminals,
1573  NodeArray<bool>& isTerminal, std::istream& is) {
1574  wG.clear();
1575  GraphAttributes attr(wG, getEdgeWeightFlag<T>());
1576  bool res = readSTP(attr, wG, terminals, isTerminal, is);
1577  for (edge e : wG.edges) {
1578  wG.setWeight(e, getEdgeWeightAttribute<T>(attr, e));
1579  }
1580  return res;
1581  }
1582 
1600  static OGDF_EXPORT bool writeSTP(const GraphAttributes& attr, const List<node>& terminals,
1601  std::ostream& os, const string& comments = "");
1602 
1615  template<typename T>
1616  static bool writeSTP(const EdgeWeightedGraph<T>& wG, const List<node>& terminals,
1617  std::ostream& os, const string& comments = "") {
1618  GraphAttributes attr(wG, getEdgeWeightFlag<T>());
1619  for (edge e : wG.edges) {
1620  getEdgeWeightAttribute<T>(attr, e) = wG.weight(e);
1621  }
1622  return writeSTP(attr, terminals, os, comments);
1623  }
1624 
1626 
1627 #pragma mark DMF
1628 
1633 
1640  static OGDF_EXPORT bool readDMF(GraphAttributes& attr, Graph& graph, node& source, node& sink,
1641  std::istream& is);
1642 
1652  static OGDF_EXPORT bool readDMF(GraphAttributes& attr, Graph& graph, std::istream& is) {
1653  node sink;
1654  node source;
1655  return readDMF(attr, graph, sink, source, is);
1656  };
1657 
1670  template<typename T>
1671  static bool readDMF(Graph& graph, EdgeArray<T>& weights, node& source, node& sink,
1672  std::istream& is) {
1673  GraphAttributes attr(graph, getEdgeWeightFlag<T>());
1674  bool result = readDMF(attr, graph, source, sink, is);
1675  weights.init(graph);
1676  for (edge e : graph.edges) {
1677  weights[e] = getEdgeWeightAttribute<T>(attr, e);
1678  }
1679  return result;
1680  }
1681 
1690  static OGDF_EXPORT bool readDMF(Graph& graph, std::istream& is) {
1691  GraphAttributes attr(graph);
1692  node source;
1693  node sink;
1694  return readDMF(attr, graph, source, sink, is);
1695  }
1696 
1710  static OGDF_EXPORT bool writeDMF(const GraphAttributes& attr, const node source,
1711  const node sink, std::ostream& os);
1712 
1724  template<typename T>
1725  static bool writeDMF(const Graph& graph, const EdgeArray<T>& weights, const node source,
1726  const node sink, std::ostream& os) {
1727  GraphAttributes attr(graph, getEdgeWeightFlag<T>());
1728  for (edge e : graph.edges) {
1729  getEdgeWeightAttribute<T>(attr, e) = weights[e];
1730  }
1731  return writeDMF(attr, source, sink, os);
1732  }
1733 
1734 #pragma mark TsplibXml
1735 
1740 
1743 
1748  static OGDF_EXPORT bool readTsplibXml(Graph& G, std::istream& is);
1749 
1751 
1759  static OGDF_EXPORT bool readTsplibXml(GraphAttributes& GA, Graph& G, std::istream& is);
1761 
1763 
1768 
1771 
1779  static OGDF_EXPORT bool readEdgeListSubgraph(Graph& G, List<edge>& delEdges, std::istream& is);
1780 
1782 
1790  static OGDF_EXPORT bool writeEdgeListSubgraph(const Graph& G, const List<edge>& delEdges,
1791  std::ostream& os);
1792 
1794 
1798 
1800  static OGDF_EXPORT bool drawSVG(const GraphAttributes& A, std::ostream& os,
1801  const SVGSettings& settings);
1802 
1803  static inline bool drawSVG(const GraphAttributes& A, std::ostream& os) {
1804  // we may not use a defaulted argument settings=svgSettings here if drawSVG should be a AttrWriterFunc:
1805  // https://stackoverflow.com/a/2225426/805569
1806  return drawSVG(A, os, svgSettings);
1807  }
1808 
1809  static inline bool drawSVG(const GraphAttributes& A, const string& filename,
1810  const SVGSettings& settings = svgSettings) {
1811  std::ofstream os(filename);
1812  return os.good() && drawSVG(A, os, settings);
1813  }
1814 
1815  static OGDF_EXPORT bool drawSVG(const ClusterGraphAttributes& A, std::ostream& os,
1816  const SVGSettings& settings);
1817 
1818  static inline bool drawSVG(const ClusterGraphAttributes& A, std::ostream& os) {
1819  return drawSVG(A, os, svgSettings);
1820  }
1821 
1822  static inline bool drawSVG(const ClusterGraphAttributes& A, const string& filename,
1823  const SVGSettings& settings = svgSettings) {
1824  std::ofstream os(filename);
1825  return os.good() && drawSVG(A, os, settings);
1826  }
1827 
1835  static OGDF_EXPORT bool drawTikz(const GraphAttributes& A, std::ostream& os);
1836 
1844  static OGDF_EXPORT bool drawTikz(const ClusterGraphAttributes& A, std::ostream& os);
1845 
1847 
1852 
1855  static char indentChar() { return s_indentChar; }
1856 
1858  static int indentWidth() { return s_indentWidth; }
1859 
1861 
1864  static void setIndentChar(char c) {
1865  OGDF_ASSERT(isspace((int)c));
1866  s_indentChar = c;
1867  }
1868 
1870 
1874  static void setIndentWidth(int w) {
1875  if (w >= 0) {
1876  s_indentWidth = w;
1877  }
1878  }
1879 
1881  static OGDF_EXPORT std::ostream& indent(std::ostream& os, int depth);
1882 
1886 
1889  static OGDF_EXPORT bool setColorValue(int value, std::function<void(uint8_t)> setFunction) {
1890  if (value < 0 || value > 255) {
1891  GraphIO::logger.lout() << "Error: color value is not between 0 and 255." << std::endl;
1892  return false;
1893  }
1894  setFunction(static_cast<uint8_t>(value));
1895  return true;
1896  }
1897 
1899 
1902  template<typename T, typename std::enable_if<std::is_integral<T>::value, bool>::type = 0>
1903  static long getEdgeWeightFlag() {
1905  }
1906 
1908 
1911  template<typename T, typename std::enable_if<std::is_floating_point<T>::value, bool>::type = 0>
1912  static long getEdgeWeightFlag() {
1914  }
1915 
1917 
1922  template<typename T, typename std::enable_if<std::is_integral<T>::value, bool>::type = 0>
1924  return attr.intWeight(e);
1925  }
1926 
1928 
1933  template<typename T, typename std::enable_if<std::is_floating_point<T>::value, bool>::type = 0>
1934  static double& getEdgeWeightAttribute(GraphAttributes& attr, edge e) {
1935  return attr.doubleWeight(e);
1936  }
1937 
1939 
1941 
1942 private:
1945 };
1946 
1947 }
ogdf::GraphAttributes::edgeIntWeight
static const long edgeIntWeight
Corresponds to edge attribute intWeight(edge).
Definition: GraphAttributes.h:125
ogdf::GraphIO::ClusterAttrWriterFunc
bool(*)(const ClusterGraphAttributes &, std::ostream &) ClusterAttrWriterFunc
Type of cluster graph attributes writer functions working on streams.
Definition: GraphIO.h:89
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:72
GraphAttributes.h
Declaration of class GraphAttributes which extends a Graph by additional attributes.
ogdf::GraphIO::readSTP
static bool readSTP(Graph &G, std::istream &is)
Reads a graph in SteinLib format from std::istream is.
Definition: GraphIO.h:1553
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:79
ogdf::GraphIO::readChaco
static bool readChaco(Graph &G, std::istream &is)
Reads graph G in Chaco format from input stream is.
Graph.h
Includes declaration of graph class.
ogdf::GraphIO::getEdgeWeightAttribute
static int & getEdgeWeightAttribute(GraphAttributes &attr, edge e)
Returns a reference to the intWeight()-value of attr for e.
Definition: GraphIO.h:1923
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:1855
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.
ogdf::GraphIO::SVGSettings::m_width
string m_width
Definition: GraphIO.h:135
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
ogdf::GraphIO::SVGSettings::fontFamily
const string & fontFamily() const
Returns the default font family.
Definition: GraphIO.h:157
ogdf::EdgeWeightedGraph::weight
T weight(const edge e) const
Definition: EdgeWeightedGraph.h:59
ogdf::GraphIO::FileType::extensions
std::vector< std::string > extensions
Definition: GraphIO.h:92
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:131
ogdf::GraphIO::getFileType
static const FileType * getFileType(const string &filename)
ogdf::GraphIO::SVGSettings::m_fontSize
int m_fontSize
Definition: GraphIO.h:130
ogdf::GraphIO::FileType::auto_cluster_attr_reader_func
ClusterAttrReaderFunc auto_cluster_attr_reader_func
Definition: GraphIO.h:103
ogdf::GraphIO::drawSVG
static bool drawSVG(const GraphAttributes &A, std::ostream &os)
Definition: GraphIO.h:1803
ogdf::whaType::A
@ A
ogdf::GraphIO::svgSettings
static SVGSettings svgSettings
Definition: GraphIO.h:1940
ogdf::GraphIO::SVGSettings::curviness
void curviness(double value)
Sets the curviness of all edges (value ranges from 0 to 1).
Definition: GraphIO.h:169
ogdf::GraphIO::setIndentWidth
static void setIndentWidth(int w)
Sets the indentation width to w.
Definition: GraphIO.h:1874
ogdf::GraphIO::drawSVG
static bool drawSVG(const ClusterGraphAttributes &A, const string &filename, const SVGSettings &settings=svgSettings)
Definition: GraphIO.h:1822
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:70
ogdf::GraphIO::SVGSettings::fontSize
int fontSize() const
Returns the default font size (font height in pixels).
Definition: GraphIO.h:151
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:1540
ogdf::GraphIO::AttrWriterFunc
bool(*)(const GraphAttributes &, std::ostream &) AttrWriterFunc
Type of simple graph attributes writer functions working on streams.
Definition: GraphIO.h:76
ogdf::GraphIO::FileType::reader_func
ReaderFunc reader_func
Definition: GraphIO.h:93
ogdf::GraphIO::readRudy
static bool readRudy(Graph &G, std::istream &is)
Reads graph G in Rudy format from input stream is.
Definition: GraphIO.h:924
ogdf::GraphIO::FileType::auto_reader_func
ReaderFunc auto_reader_func
Definition: GraphIO.h:94
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:145
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:1725
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:1616
ogdf::GraphIO::FileType::cluster_attr_writer_func
ClusterAttrWriterFunc cluster_attr_writer_func
Definition: GraphIO.h:104
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:183
ogdf::GraphIO::logger
static Logger logger
Definition: GraphIO.h:64
ogdf::GraphIO::ClusterWriterFunc
bool(*)(const ClusterGraph &, std::ostream &) ClusterWriterFunc
Type of cluster graph writer functions working on streams.
Definition: GraphIO.h:82
ogdf::GraphIO::SVGSettings::width
void width(const string &width)
Sets the width.
Definition: GraphIO.h:192
ogdf::GraphIO::readMatrixMarket
static bool readMatrixMarket(Graph &G, std::istream &inStream)
Reads graph G in Matrix Market exchange format from stream inStream.
Logger.h
Contains logging functionality.
ogdf::GraphIO::s_indentChar
static char s_indentChar
Character used for indentation.
Definition: GraphIO.h:1943
ogdf::GraphIO::FileType
Definition: GraphIO.h:91
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::ClusterGraphAttributes
Stores additional attributes of a clustered graph (like layout information).
Definition: ClusterGraphAttributes.h:52
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:96
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:1889
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:163
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:1652
ogdf::GraphIO::SVGSettings
Condensed settings for drawing SVGs.
Definition: GraphIO.h:128
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:86
ogdf::GraphIO
Utility class providing graph I/O in various exchange formats.
Definition: GraphIO.h:62
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:1858
ogdf::EdgeWeightedGraph
Definition: GraphIO.h:56
GraphList.h
Decralation of GraphElement and GraphList classes.
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:101
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:1903
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:166
ogdf::GraphIO::AttrReaderFunc
bool(*)(GraphAttributes &, Graph &, std::istream &) AttrReaderFunc
Type of simple graph attributes reader functions working on streams.
Definition: GraphIO.h:73
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:1671
ogdf::List
Doubly linked lists (maintaining the length of the list).
Definition: DfsMakeBiconnected.h:40
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::GraphIO::FileType::attr_writer_func
AttrWriterFunc attr_writer_func
Definition: GraphIO.h:98
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:869
ogdf::GraphIO::SVGSettings::width
const string & width() const
Returns the default width.
Definition: GraphIO.h:160
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:1690
ogdf::GraphIO::getEdgeWeightAttribute
static double & getEdgeWeightAttribute(GraphAttributes &attr, edge e)
Returns a reference to the doubleWeight()-value of attr for e.
Definition: GraphIO.h:1934
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:935
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:177
ogdf::GraphIO::drawSVG
static bool drawSVG(const GraphAttributes &A, const string &filename, const SVGSettings &settings=svgSettings)
Definition: GraphIO.h:1809
ogdf::GraphIO::FileType::auto_cluster_reader_func
ClusterReaderFunc auto_cluster_reader_func
Definition: GraphIO.h:100
ogdf::GraphIO::SVGSettings::fontSize
void fontSize(int fs)
Sets the default font size (font height in pixels) to fs.
Definition: GraphIO.h:180
basic.h
Basic declarations, included by all source files.
ogdf::GraphIO::drawSVG
static bool drawSVG(const ClusterGraphAttributes &A, std::ostream &os)
Definition: GraphIO.h:1818
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:154
ogdf::GraphIO::SVGSettings::m_fontColor
string m_fontColor
Definition: GraphIO.h:133
ogdf::GraphIO::SVGSettings::m_height
string m_height
Definition: GraphIO.h:136
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:99
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:95
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:363
ogdf::GraphIO::ReaderFunc
bool(*)(Graph &, std::istream &) ReaderFunc
Type of simple graph reader functions working on streams.
Definition: GraphIO.h:67
ClusterGraph.h
Derived class of GraphObserver providing additional functionality to handle clustered graphs.
List.h
Declaration of doubly linked lists and iterators.
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:148
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:858
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:47
ogdf::GraphIO::s_indentWidth
static int s_indentWidth
Number of indent characters used for indentation.
Definition: GraphIO.h:1944
ogdf::GraphIO::SVGSettings::bezierInterpolation
bool bezierInterpolation() const
Returns whether Bézier-interpolation for curved edges is enabled.
Definition: GraphIO.h:142
ogdf::GraphAttributes::intWeight
int intWeight(edge e) const
Returns the (integer) weight of edge e.
Definition: GraphAttributes.h:774
ogdf::GraphIO::setIndentChar
static void setIndentChar(char c)
Sets the indentation character to c.
Definition: GraphIO.h:1864
ogdf::GraphAttributes::edgeDoubleWeight
static const long edgeDoubleWeight
Corresponds to edge attribute doubleWeight(edge).
Definition: GraphAttributes.h:128
ogdf::GraphIO::FILE_TYPES
static const std::vector< FileType > FILE_TYPES
Definition: GraphIO.h:120
ogdf::GraphIO::FileType::auto_attr_reader_func
AttrReaderFunc auto_attr_reader_func
Definition: GraphIO.h:97
ogdf::GraphAttributes::doubleWeight
double doubleWeight(edge e) const
Returns the (real number) weight of edge e.
Definition: GraphAttributes.h:792
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:134
ogdf::Logger
Centralized global and local logging facility working on streams like std::cout.
Definition: Logger.h:102
ogdf::EdgeWeightedGraph::setWeight
void setWeight(const edge e, T weight)
Definition: EdgeWeightedGraph.h:63
ogdf::GraphIO::FILE_TYPE_MAP
static std::unordered_map< string, const FileType * > FILE_TYPE_MAP
Definition: GraphIO.h:121
ogdf::GraphIO::SVGSettings::fontFamily
void fontFamily(const string &fm)
Sets the default font family to fm.
Definition: GraphIO.h:186
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:1572
ogdf::GraphIO::SVGSettings::m_margin
double m_margin
Definition: GraphIO.h:129
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:346
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::GraphIO::readTLP
static bool readTLP(Graph &G, std::istream &is)
Reads graph G in TLP format from input stream is.
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:198
ogdf::GraphIO::FileType::cluster_attr_reader_func
ClusterAttrReaderFunc cluster_attr_reader_func
Definition: GraphIO.h:102
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716
ogdf::GraphIO::SVGSettings::m_bezierInterpolation
bool m_bezierInterpolation
Definition: GraphIO.h:132
ogdf::Logger::lout
std::ostream & lout(Level level=Level::Default, bool indent=true) const
stream for logging-output (local)
Definition: Logger.h:160
ogdf::GraphIO::writeSparse6
static bool writeSparse6(const Graph &G, std::ostream &os)
Writes graph G in Sparse6 format to output stream os.