Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

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&, 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 
73  using ClusterAttrReaderFunc = bool (*)(ClusterGraphAttributes&, ClusterGraph&, Graph&, std::istream&);
74 
76  using ClusterAttrWriterFunc = bool (*)(const ClusterGraphAttributes&, std::ostream&);
77 
80  {
81  double m_margin;
83  double m_curviness;
85  string m_fontColor;
86  string m_fontFamily;
87  string m_width;
88  string m_height;
89 
90  public:
91  SVGSettings();
92 
94  bool bezierInterpolation() const { return m_bezierInterpolation; }
95 
97  double margin() const { return m_margin; }
98 
100  double curviness() const { return m_curviness; }
101 
103  int fontSize() const { return m_fontSize; }
104 
106  const string &fontColor() const { return m_fontColor; }
107 
109  const string &fontFamily() const { return m_fontFamily; }
110 
112  const string &width() const { return m_width; }
113 
115  const string &height() const { return m_height; }
116 
118  void margin(double m) { m_margin = m; }
119 
121  void curviness(double value) {
122  OGDF_ASSERT(value >= 0);
123  OGDF_ASSERT(value <= 1);
124 
125  m_curviness = value;
126  }
127 
129  void bezierInterpolation(bool enable) { m_bezierInterpolation = enable; }
130 
132  void fontSize(int fs) { m_fontSize = fs; }
133 
135  void fontColor(const string &fc) { m_fontColor = fc; }
136 
138  void fontFamily(const string &fm) { m_fontFamily = fm; }
139 
141 
144  void width(const string &width) { m_width = width; }
145 
147 
150  void height(const string &height) { m_height = height; }
151  };
152 
158 
160 
166  static inline bool read(Graph &G, const string &filename, ReaderFunc reader = GraphIO::read) {
167  std::ifstream is(filename);
168  return is.good() && reader(G, is);
169  }
170 
172 
178  static inline bool write(const Graph &G, const string &filename, WriterFunc writer) {
179  std::ofstream os(filename);
180  return os.good() && writer(G, os);
181  }
182 
184 
192  static OGDF_EXPORT bool write(const Graph &G, const string &filename);
193 
195 
218  static OGDF_EXPORT bool read(Graph &G, std::istream &is);
219 
222 
240  static OGDF_EXPORT bool read(GraphAttributes &GA, Graph &G, std::istream &is);
241 
243 
250  static bool read(GraphAttributes &GA, Graph &G, const string &filename, AttrReaderFunc reader) {
251  std::ifstream is(filename);
252  return is.good() && reader(GA, G, is);
253  }
254 
256 
262  static bool write(const GraphAttributes &GA, const string &filename, AttrWriterFunc writer) {
263  std::ofstream os(filename);
264  return os.good() && writer(GA, os);
265  }
266 
268 
269 #pragma mark GML
270 
276 
278 
290  static OGDF_EXPORT bool readGML(Graph &G, std::istream &is);
291 
293 
305  static OGDF_EXPORT bool writeGML(const Graph &G, std::ostream &os);
306 
308 
317  static OGDF_EXPORT bool readGML(ClusterGraph &C, Graph &G, std::istream &is);
318 
320 
327  static OGDF_EXPORT bool writeGML(const ClusterGraph &C, std::ostream &os);
328 
330 
340  static OGDF_EXPORT bool readGML(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, std::istream &is);
341 
343 
350  static OGDF_EXPORT bool writeGML(const ClusterGraphAttributes &A, std::ostream &os);
351 
353 
362  static OGDF_EXPORT bool readGML(GraphAttributes &A, Graph &G, std::istream &is);
363 
365 
372  static OGDF_EXPORT bool writeGML(const GraphAttributes &A, std::ostream &os);
373 
375 
376 #pragma mark Rome
377 
383 
385 
398  static OGDF_EXPORT bool readRome(Graph &G, std::istream &is);
399 
401 
408  static OGDF_EXPORT bool writeRome(const Graph &G, std::ostream &os);
409 
411 
412 #pragma mark LEDA
413 
419 
421 
434  static OGDF_EXPORT bool readLEDA(Graph &G, std::istream &is);
435 
437 
450  static OGDF_EXPORT bool writeLEDA(const Graph &G, std::ostream &os);
451 
453 
454 #pragma mark Chaco
455 
461 
463 
476  static OGDF_EXPORT bool readChaco(Graph &G, std::istream &is);
477 
479 
492  static OGDF_EXPORT bool writeChaco(const Graph &G, std::ostream &os);
493 
495 
496 #pragma mark PMDissGraph
497 
503 
505 
520  static OGDF_EXPORT bool readPMDissGraph(Graph &G, std::istream &is);
521 
523 
538  static OGDF_EXPORT bool writePMDissGraph(const Graph &G, std::ostream &os);
539 
541 
542 #pragma mark YGraph
543 
549 
551 
571  static OGDF_EXPORT bool readYGraph(Graph &G, std::istream &is);
572 
574 
575 #pragma mark Graph6
576 
585 
587 
595  static OGDF_EXPORT bool readGraph6(Graph &G, std::istream &is, bool forceHeader = false);
596 
598 
605  static OGDF_EXPORT bool writeGraph6(const Graph &G, std::ostream &os);
606 
608 
609 #pragma mark Digraph6
610 
618 
620 
628  static OGDF_EXPORT bool readDigraph6(Graph &G, std::istream &is, bool forceHeader = false);
629 
631 
638  static OGDF_EXPORT bool writeDigraph6(const Graph &G, std::ostream &os);
639 
641 
642 #pragma mark Sparse6
643 
651 
653 
661  static OGDF_EXPORT bool readSparse6(Graph &G, std::istream &is, bool forceHeader = false);
662 
664 
671  static OGDF_EXPORT bool writeSparse6(const Graph &G, std::ostream &os);
672 
674 
675 #pragma mark MatrixMarket
676 
682 
684 
689  static OGDF_EXPORT bool readMatrixMarket(Graph& G, std::istream &inStream);
690 
692 
693 #pragma mark Rudy
694 
698 
700 
709  static OGDF_EXPORT bool readRudy(GraphAttributes &A, Graph &G, std::istream &is);
710 
712 
719  static OGDF_EXPORT bool readRudy(Graph &G, std::istream &is) {
721  return readRudy(A, G, is);
722  }
723 
725 
733  static OGDF_EXPORT bool writeRudy(const GraphAttributes &A, std::ostream &os);
734 
736 
737 #pragma mark BENCH
738 
742 
744 
761  static OGDF_EXPORT bool readBENCH(Graph &G, List<node>& hypernodes, List<edge> *shell, std::istream &is);
762 
764 
765 #pragma mark PLA
766 
770 
772 
789  static OGDF_EXPORT bool readPLA(Graph &G, List<node>& hypernodes, List<edge> *shell, std::istream &is);
790 
792 
793 #pragma mark ChallengeGraph
794 
801 
803 
812  static OGDF_EXPORT bool readChallengeGraph(Graph &G, GridLayout &gl, std::istream &is);
813 
815 
824  static OGDF_EXPORT bool writeChallengeGraph(const Graph &G, const GridLayout &gl, std::ostream &os);
825 
827 
828 #pragma mark GraphML
829 
835 
837 
844  static OGDF_EXPORT bool readGraphML(Graph &G, std::istream &is);
845 
847 
856  static OGDF_EXPORT bool readGraphML(ClusterGraph &C, Graph &G, std::istream &is);
857 
859 
868  static OGDF_EXPORT bool readGraphML(GraphAttributes &A, Graph &G, std::istream &is);
869 
871 
881  static OGDF_EXPORT bool readGraphML(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, std::istream &is);
882 
884 
890  static OGDF_EXPORT bool writeGraphML(const Graph &G, std::ostream &os);
891 
893 
899  static OGDF_EXPORT bool writeGraphML(const ClusterGraph &C, std::ostream &os);
900 
902 
908  static OGDF_EXPORT bool writeGraphML(const GraphAttributes &A, std::ostream &os);
909 
911 
917  static OGDF_EXPORT bool writeGraphML(const ClusterGraphAttributes &A, std::ostream &os);
918 
920 
921 #pragma mark DOT
922 
928 
930 
937  static OGDF_EXPORT bool readDOT(Graph &G, std::istream &is);
938 
940 
949  static OGDF_EXPORT bool readDOT(ClusterGraph &C, Graph &G, std::istream &is);
950 
952 
961  static OGDF_EXPORT bool readDOT(GraphAttributes &A, Graph &G, std::istream &is);
962 
964 
974  static OGDF_EXPORT bool readDOT(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, std::istream &is);
975 
977 
983  static OGDF_EXPORT bool writeDOT(const Graph &G, std::ostream &os);
984 
986 
992  static OGDF_EXPORT bool writeDOT(const ClusterGraph &C, std::ostream &os);
993 
995 
1001  static OGDF_EXPORT bool writeDOT(const GraphAttributes &A, std::ostream &os);
1002 
1004 
1010  static OGDF_EXPORT bool writeDOT(const ClusterGraphAttributes &A, std::ostream &os);
1011 
1013 
1014 #pragma mark GEXF
1015 
1021 
1023 
1030  static OGDF_EXPORT bool readGEXF(Graph &G, std::istream &is);
1031 
1033 
1042  static OGDF_EXPORT bool readGEXF(ClusterGraph &C, Graph &G, std::istream &is);
1043 
1045 
1054  static OGDF_EXPORT bool readGEXF(GraphAttributes &A, Graph &G, std::istream &is);
1055 
1057 
1067  static OGDF_EXPORT bool readGEXF(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, std::istream &is);
1068 
1070 
1076  static OGDF_EXPORT bool writeGEXF(const Graph &G, std::ostream &os);
1077 
1079 
1085  static OGDF_EXPORT bool writeGEXF(const ClusterGraph &C, std::ostream &os);
1086 
1088 
1094  static OGDF_EXPORT bool writeGEXF(const GraphAttributes &A, std::ostream &os);
1095 
1097 
1103  static OGDF_EXPORT bool writeGEXF(const ClusterGraphAttributes &A, std::ostream &os);
1104 
1106 
1107 #pragma mark GDF
1108 
1114 
1116 
1123  static OGDF_EXPORT bool readGDF(Graph &G, std::istream &is);
1124 
1126 
1135  static OGDF_EXPORT bool readGDF(GraphAttributes &A, Graph &G, std::istream &is);
1136 
1138 
1144  static OGDF_EXPORT bool writeGDF(const Graph &G, std::ostream &os);
1145 
1147 
1153  static OGDF_EXPORT bool writeGDF(const GraphAttributes &A, std::ostream &os);
1154 
1156 
1157 #pragma mark TLP
1158 
1164 
1166 
1173  static OGDF_EXPORT bool readTLP(Graph &G, std::istream &is);
1174 
1176 
1185  static OGDF_EXPORT bool readTLP(ClusterGraph &C, Graph &G, std::istream &is);
1186 
1188 
1197  static OGDF_EXPORT bool readTLP(GraphAttributes &A, Graph &G, std::istream &is);
1198 
1200 
1210  static OGDF_EXPORT bool readTLP(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, std::istream &is);
1211 
1213 
1219  static OGDF_EXPORT bool writeTLP(const Graph &G, std::ostream &os);
1220 
1222 
1228  static OGDF_EXPORT bool writeTLP(const ClusterGraph &C, std::ostream &os);
1229 
1231 
1237  static OGDF_EXPORT bool writeTLP(const GraphAttributes &A, std::ostream &os);
1238 
1240 
1246  static OGDF_EXPORT bool writeTLP(const ClusterGraphAttributes &A, std::ostream &os);
1247 
1249 
1250 #pragma mark DL
1251 
1257 
1259 
1266  static OGDF_EXPORT bool readDL(Graph &G, std::istream &is);
1267 
1269 
1278  static OGDF_EXPORT bool readDL(GraphAttributes &A, Graph &G, std::istream &is);
1279 
1281 
1287  static OGDF_EXPORT bool writeDL(const Graph &G, std::ostream &os);
1288 
1290 
1296  static OGDF_EXPORT bool writeDL(const GraphAttributes &A, std::ostream &os);
1297 
1299 
1300 #pragma mark STP
1301 
1307 
1315  static OGDF_EXPORT bool readSTP(GraphAttributes &attr, Graph &G, List<node> &terminals, NodeArray<bool> &isTerminal, std::istream &is);
1316 
1327  static OGDF_EXPORT bool readSTP(GraphAttributes &attr, Graph &G, std::istream &is) {
1328  List<node> terminals;
1329  NodeArray<bool> isTerminal;
1330  return readSTP(attr, G, terminals, isTerminal, is);
1331  }
1332 
1340  static OGDF_EXPORT bool readSTP(Graph &G, std::istream &is) {
1341  GraphAttributes attr(G);
1342  return readSTP(attr, G, is);
1343  }
1344 
1358  template<typename T>
1359  static bool readSTP(
1361  List<node> &terminals,
1362  NodeArray<bool> &isTerminal,
1363  std::istream &is)
1364  {
1365  wG.clear();
1366  GraphAttributes attr(wG, getEdgeWeightFlag<T>());
1367  bool res = readSTP(attr, wG, terminals, isTerminal, is);
1368  for (edge e : wG.edges) {
1369  wG.setWeight(e, getEdgeWeightAttribute<T>(attr, e));
1370  }
1371  return res;
1372  }
1373 
1391  static OGDF_EXPORT bool writeSTP(
1392  const GraphAttributes &attr,
1393  const List<node> &terminals,
1394  std::ostream &os,
1395  const string &comments = "");
1396 
1409  template<typename T>
1410  static bool writeSTP(
1411  const EdgeWeightedGraph<T> &wG,
1412  const List<node> &terminals,
1413  std::ostream &os,
1414  const string &comments = "")
1415  {
1416  GraphAttributes attr(wG, getEdgeWeightFlag<T>());
1417  for (edge e : wG.edges) {
1418  getEdgeWeightAttribute<T>(attr, e) = wG.weight(e);
1419  }
1420  return writeSTP(attr, terminals, os, comments);
1421  }
1422 
1424 
1425 #pragma mark DMF
1426 
1432 
1438  static OGDF_EXPORT bool readDMF(GraphAttributes &attr, Graph &graph, node &source, node &sink, std::istream &is);
1439 
1449  static OGDF_EXPORT bool readDMF(GraphAttributes &attr, Graph &graph, std::istream &is) {
1450  node sink;
1451  node source;
1452  return readDMF(attr, graph, sink, source, is);
1453  };
1454 
1467  template<typename T>
1468  static bool readDMF(Graph &graph, EdgeArray<T> &weights, node &source, node &sink, std::istream &is) {
1469  GraphAttributes attr(graph, getEdgeWeightFlag<T>());
1470  bool result = readDMF(attr, graph, source, sink, is);
1471  weights.init(graph);
1472  for (edge e : graph.edges) {
1473  weights[e] = getEdgeWeightAttribute<T>(attr, e);
1474  }
1475  return result;
1476  }
1477 
1486  static OGDF_EXPORT bool readDMF(Graph &graph, std::istream &is) {
1487  GraphAttributes attr(graph);
1488  node source;
1489  node sink;
1490  return readDMF(attr, graph, source, sink, is);
1491  }
1492 
1506  static OGDF_EXPORT bool writeDMF(
1507  const GraphAttributes &attr,
1508  const node source,
1509  const node sink,
1510  std::ostream &os);
1511 
1523  template<typename T>
1524  static bool writeDMF(
1525  const Graph &graph,
1526  const EdgeArray<T> &weights,
1527  const node source,
1528  const node sink,
1529  std::ostream &os)
1530  {
1531  GraphAttributes attr(graph, getEdgeWeightFlag<T>());
1532  for (edge e : graph.edges) {
1533  getEdgeWeightAttribute<T>(attr, e) = weights[e];
1534  }
1535  return writeDMF(attr, source, sink, os);
1536  }
1537 
1539 
1545 
1547 
1555  static OGDF_EXPORT bool readEdgeListSubgraph(Graph &G, List<edge> &delEdges, std::istream &is);
1556 
1558 
1566  static OGDF_EXPORT bool writeEdgeListSubgraph(const Graph &G, const List<edge> &delEdges, std::ostream &os);
1567 
1569 
1574 
1575  static OGDF_EXPORT bool drawSVG(const GraphAttributes &A, std::ostream &os, const SVGSettings &settings);
1576  static inline bool drawSVG(const GraphAttributes &A, std::ostream &os) {
1577  return drawSVG(A, os, svgSettings);
1578  }
1579 
1580  static OGDF_EXPORT bool drawSVG(const ClusterGraphAttributes &A, std::ostream &os, const SVGSettings &settings);
1581  static inline bool drawSVG(const ClusterGraphAttributes &A, std::ostream &os) {
1582  return drawSVG(A, os, svgSettings);
1583  }
1584 
1586 
1592 
1594  static char indentChar() { return s_indentChar; }
1595 
1597  static int indentWidth() { return s_indentWidth; }
1598 
1600 
1603  static void setIndentChar(char c) {
1604  OGDF_ASSERT(isspace((int)c));
1605  s_indentChar = c;
1606  }
1607 
1609 
1613  static void setIndentWidth(int w) {
1614  if(w >= 0) s_indentWidth = w;
1615  }
1616 
1618  static OGDF_EXPORT std::ostream &indent(std::ostream &os, int depth);
1619 
1621 
1623 
1626  static OGDF_EXPORT bool setColorValue(int value, std::function<void(uint8_t)> setFunction)
1627  {
1628  if (value < 0 || value > 255) {
1629  GraphIO::logger.lout() << "Error: color value is not between 0 and 255." << std::endl;
1630  return false;
1631  }
1632  setFunction(static_cast<uint8_t>(value));
1633  return true;
1634  }
1635 
1637 
1640  template<typename T, typename std::enable_if<std::is_integral<T>::value, bool>::type = 0>
1641  static int getEdgeWeightFlag() {
1643  }
1644 
1646 
1649  template<typename T, typename std::enable_if<std::is_floating_point<T>::value, bool>::type = 0>
1650  static int getEdgeWeightFlag() {
1652  }
1653 
1655 
1660  template<typename T, typename std::enable_if<std::is_integral<T>::value, bool>::type = 0>
1662  return attr.intWeight(e);
1663  }
1664 
1666 
1671  template<typename T, typename std::enable_if<std::is_floating_point<T>::value, bool>::type = 0>
1672  static double &getEdgeWeightAttribute(GraphAttributes &attr, edge e) {
1673  return attr.doubleWeight(e);
1674  }
1675 
1677 
1679 
1680 private:
1681  static OGDF_EXPORT bool readGraph6WithForcedHeader(Graph &G, std::istream &is);
1682  static OGDF_EXPORT bool readDigraph6WithForcedHeader(Graph &G, std::istream &is);
1683  static OGDF_EXPORT bool readSparse6WithForcedHeader(Graph &G, std::istream &is);
1686 };
1687 
1688 }
Representation of a graph&#39;s grid layout.
Definition: GridLayout.h:46
bool(*)(const ClusterGraph &, std::ostream &) ClusterWriterFunc
Type of cluster graph writer functions working on streams.
Definition: GraphIO.h:70
static int getEdgeWeightFlag()
Returns GraphAttributes::edgeIntWeight.
Definition: GraphIO.h:1641
static bool readDigraph6(Graph &G, std::istream &is, bool forceHeader=false)
Reads graph G in Digraph6 format from input stream is.
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. ...
bool(*)(const ClusterGraphAttributes &, std::ostream &) ClusterAttrWriterFunc
Type of cluster graph attributes writer functions working on streams.
Definition: GraphIO.h:76
static std::ostream & indent(std::ostream &os, int depth)
Prints indentation for indentation depth to output stream os and returns os.
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:1524
bool(*)(GraphAttributes &, Graph &, std::istream &) AttrReaderFunc
Type of simple graph attributes reader functions working on streams.
Definition: GraphIO.h:61
std::ostream & lout(Level level=Level::Default) const
stream for logging-output (local)
Definition: Logger.h:147
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.
static bool write(const GraphAttributes &GA, const string &filename, AttrWriterFunc writer)
Writes arbitrary format to a file specified by name.
Definition: GraphIO.h:262
static bool readGEXF(Graph &G, std::istream &is)
Reads graph G in GEXF format from input stream is.
static bool writeChaco(const Graph &G, std::ostream &os)
Writes graph G in Chaco format to output stream os.
void curviness(double value)
Sets the curviness of all edges (value ranges from 0 to 1).
Definition: GraphIO.h:121
virtual void clear()
Removes all nodes and all edges from the graph.
static bool writeGraph6(const Graph &G, std::ostream &os)
Writes graph G in Graph6 format to output stream os.
static bool readPMDissGraph(Graph &G, std::istream &is)
Reads graph G in a simple format as used in Petra Mutzel&#39;s thesis from input stream is...
void init()
Reinitializes the array. Associates the array with no graph.
Definition: EdgeArray.h:283
static bool writeDigraph6(const Graph &G, std::ostream &os)
Writes graph G in Digraph6 format to output stream os.
static bool readLEDA(Graph &G, std::istream &is)
Reads graph G in LEDA graph format from input stream is.
static bool readDMF(Graph &graph, std::istream &is)
Reads a maximum flow instance in DIMACS format.
Definition: GraphIO.h:1486
static void setIndentWidth(int w)
Sets the indentation width to w.
Definition: GraphIO.h:1613
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
static bool drawSVG(const GraphAttributes &A, std::ostream &os, const SVGSettings &settings)
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
static int & getEdgeWeightAttribute(GraphAttributes &attr, edge e)
Returns a reference to the intWeight()-value of attr for e.
Definition: GraphIO.h:1661
double curviness() const
Returns the curviness of the edges (value ranges from 0 to 1).
Definition: GraphIO.h:100
static const long edgeIntWeight
Corresponds to edge attribute intWeight(edge).
static bool writeGEXF(const Graph &G, std::ostream &os)
Writes graph G in GEXF format to output stream os.
void setWeight(const edge e, T weight)
Utility class providing graph I/O in various exchange formats.
Definition: GraphIO.h:49
static bool writePMDissGraph(const Graph &G, std::ostream &os)
Writes graph G in a simple format as used in Petra Mutzel&#39;s thesis to output stream os...
static bool readDigraph6WithForcedHeader(Graph &G, std::istream &is)
static bool writeRudy(const GraphAttributes &A, std::ostream &os)
Writes graph with edge weights stored in A in Rudy format to output stream os.
Dynamic arrays indexed with edges.
Definition: EdgeArray.h:112
static bool writeSparse6(const Graph &G, std::ostream &os)
Writes graph G in Sparse6 format to output stream os.
static bool writeGDF(const Graph &G, std::ostream &os)
Writes graph G in GDF format to output stream os.
static double & getEdgeWeightAttribute(GraphAttributes &attr, edge e)
Returns a reference to the doubleWeight()-value of attr for e.
Definition: GraphIO.h:1672
static bool readGDF(Graph &G, std::istream &is)
Reads graph G in GDF format from input stream is.
static bool readGraph6(Graph &G, std::istream &is, bool forceHeader=false)
Reads graph G in Graph6 format from input stream is.
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.
static bool drawSVG(const GraphAttributes &A, std::ostream &os)
Definition: GraphIO.h:1576
static bool readSparse6WithForcedHeader(Graph &G, std::istream &is)
static bool writeRome(const Graph &G, std::ostream &os)
Writes graph G in Rome-Lib format to output stream os.
static bool readGML(Graph &G, std::istream &is)
Reads graph G in GML format from input stream is.
T weight(const edge e) const
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.
Representation of clustered graphs.
Definition: ClusterGraph.h:291
static bool read(GraphAttributes &GA, Graph &G, const string &filename, AttrReaderFunc reader)
Reads arbitrary format from a file specified by name.
Definition: GraphIO.h:250
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Definition: Graph_d.h:568
static void setIndentChar(char c)
Sets the indentation character to c.
Definition: GraphIO.h:1603
static SVGSettings svgSettings
Definition: GraphIO.h:1678
static bool writeTLP(const Graph &G, std::ostream &os)
Writes graph G in TLP format to output stream os.
static bool writeGML(const Graph &G, std::ostream &os)
Writes graph G in GML format to output stream os.
static bool readDMF(GraphAttributes &attr, Graph &graph, std::istream &is)
Reads a maximum flow instance in DIMACS format.
Definition: GraphIO.h:1449
bool(*)(const Graph &, std::ostream &) WriterFunc
Type of simple graph writer functions working on streams.
Definition: GraphIO.h:58
static bool writeDL(const Graph &G, std::ostream &os)
Writes graph G in DL format to output stream os.
static char s_indentChar
Character used for indentation.
Definition: GraphIO.h:1684
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:1626
Declaration of class GridLayout.
static const long edgeDoubleWeight
Corresponds to edge attribute doubleWeight(edge).
Stores additional attributes of a graph (like layout information).
int intWeight(edge e) const
Returns the (integer) weight of edge e.
static bool writeGraphML(const Graph &G, std::ostream &os)
Writes graph G in GraphML format to output stream os.
Doubly linked lists (maintaining the length of the list).
Definition: List.h:40
Definition of exception classes.
const string & width() const
Returns the default width.
Definition: GraphIO.h:112
int fontSize() const
Returns the default font size (font height in pixels).
Definition: GraphIO.h:103
Class for the representation of edges.
Definition: Graph_d.h:292
static bool readDL(Graph &G, std::istream &is)
Reads graph G in DL format from input stream is.
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:1410
Stores additional attributes of a clustered graph (like layout information).
Declaration of class EdgeWeightedGraph.
static bool readSTP(GraphAttributes &attr, Graph &G, std::istream &is)
Reads a graph in SteinLib format from std::istream is.
Definition: GraphIO.h:1327
static bool readSparse6(Graph &G, std::istream &is, bool forceHeader=false)
Reads graph G in Sparse6 format from input stream is.
const string & height() const
Returns the default height.
Definition: GraphIO.h:115
double margin() const
Returns the size of the margin around the drawing.
Definition: GraphIO.h:97
Class for the representation of nodes.
Definition: Graph_d.h:169
static bool readYGraph(Graph &G, std::istream &is)
Reads graph G in Y-graph format from input stream is.
static bool writeDOT(const Graph &G, std::ostream &os)
Writes graph G in DOT format to output stream os.
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.
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.
static bool readTLP(Graph &G, std::istream &is)
Reads graph G in TLP format from input stream is.
void height(const string &height)
Sets the height.
Definition: GraphIO.h:150
static bool readRome(Graph &G, std::istream &is)
Reads graph G in Rome-Lib format from input stream is.
void fontSize(int fs)
Sets the default font size (font height in pixels) to fs.
Definition: GraphIO.h:132
bool(*)(Graph &, std::istream &) ReaderFunc
Type of simple graph reader functions working on streams.
Definition: GraphIO.h:55
void width(const string &width)
Sets the width.
Definition: GraphIO.h:144
Declares ClusterGraphAttributes, an extension of class GraphAttributes, to store clustergraph layout ...
static bool readGraphML(Graph &G, std::istream &is)
Reads graph G in GraphML format from input stream is.
void margin(double m)
Sets the size of the margin around the drawing to m.
Definition: GraphIO.h:118
static int s_indentWidth
Number of indent characters used for indentation.
Definition: GraphIO.h:1685
static bool readChaco(Graph &G, std::istream &is)
Reads graph G in Chaco format from input stream is.
static bool readDMF(GraphAttributes &attr, Graph &graph, node &source, node &sink, std::istream &is)
Reads a maximum flow instance in DIMACS format.
bool(*)(ClusterGraph &, Graph &, std::istream &) ClusterReaderFunc
Type of cluster graph reader functions working on streams.
Definition: GraphIO.h:67
static bool readMatrixMarket(Graph &G, std::istream &inStream)
Reads graph G in Matrix Market exchange format from stream inStream.
static bool readDOT(Graph &G, std::istream &is)
Reads graph G in DOT format from input stream is.
Condensed settings for drawing SVGs.
Definition: GraphIO.h:79
Centralized global and local logging facility working on streams like std::cout.
Definition: Logger.h:99
bool bezierInterpolation() const
Returns whether Bézier-interpolation for curved edges is enabled.
Definition: GraphIO.h:94
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.
static bool write(const Graph &G, const string &filename, WriterFunc writer)
Writes arbitrary format to a file specified by name.
Definition: GraphIO.h:178
static bool drawSVG(const ClusterGraphAttributes &A, std::ostream &os)
Definition: GraphIO.h:1581
static bool readSTP(Graph &G, std::istream &is)
Reads a graph in SteinLib format from std::istream is.
Definition: GraphIO.h:1340
static bool writeLEDA(const Graph &G, std::ostream &os)
Writes graph G in LEDA graph format to output stream os.
static int indentWidth()
Returns the currently used indentation width.
Definition: GraphIO.h:1597
const string & fontFamily() const
Returns the default font family.
Definition: GraphIO.h:109
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:1359
void fontFamily(const string &fm)
Sets the default font family to fm.
Definition: GraphIO.h:138
void fontColor(const string &fc)
Sets the default font color to fc.
Definition: GraphIO.h:135
void bezierInterpolation(bool enable)
Enables or disables Bézier-interpolation.
Definition: GraphIO.h:129
double doubleWeight(edge e) const
Returns the (real number) weight of edge e.
static bool readRudy(Graph &G, std::istream &is)
Reads graph G in Rudy format from input stream is.
Definition: GraphIO.h:719
The namespace for all OGDF objects.
const string & fontColor() const
Returns the default font color.
Definition: GraphIO.h:106
bool(*)(const GraphAttributes &, std::ostream &) AttrWriterFunc
Type of simple graph attributes writer functions working on streams.
Definition: GraphIO.h:64
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.
static bool writeEdgeListSubgraph(const Graph &G, const List< edge > &delEdges, std::ostream &os)
Writes graph G with subgraph defined by delEdges to stream os.
static char indentChar()
Returns the currently used indentation character.
Definition: GraphIO.h:1594
bool(*)(ClusterGraphAttributes &, ClusterGraph &, Graph &, std::istream &) ClusterAttrReaderFunc
Type of cluster graph attributes reader functions working on streams.
Definition: GraphIO.h:73
static bool readGraph6WithForcedHeader(Graph &G, std::istream &is)
#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:166
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:1468
static bool readEdgeListSubgraph(Graph &G, List< edge > &delEdges, std::istream &is)
Reads graph G with subgraph defined by delEdges from stream is.
static Logger logger
Definition: GraphIO.h:52