Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
GraphIO.h
Go to the documentation of this file.
1
33#pragma once
34
39
40#include <sstream>
41#include <unordered_map>
42
43namespace ogdf {
44
45
47
50class GraphIO {
51public:
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
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;
123 string m_width;
124 string m_height;
125
126 public:
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
308
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
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
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
468
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
576
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
612
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
654
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
696
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
742
744
764 static OGDF_EXPORT bool readYGraph(Graph& G, std::istream& is);
765
767
768#pragma mark Graph6
778
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
811
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
844
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
875
877
882 static OGDF_EXPORT bool readMatrixMarket(Graph& G, std::istream& inStream);
883
885
886#pragma mark Rudy
891
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
935
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
964
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
996
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
1031
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
1125
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
1219
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
1313
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
1363
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
1457
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
1507
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) {
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();
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 = "") {
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
1622
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) {
1662 bool result = readDMF(attr, graph, source, sink, is);
1663 weights.init(graph);
1664 for (edge e : graph.edges) {
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) {
1716 for (edge e : graph.edges) {
1718 }
1719 return writeDMF(attr, source, sink, os);
1720 }
1721
1722#pragma mark TsplibXml
1729
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
1757
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
1787
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
1841
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
1891 static long getEdgeWeightFlag() {
1893 }
1894
1896
1900 static long getEdgeWeightFlag() {
1902 }
1903
1905
1912 return attr.intWeight(e);
1913 }
1914
1916
1923 return attr.doubleWeight(e);
1924 }
1925
1927
1929
1930private:
1933};
1934
1935}
Declares ClusterGraphAttributes, an extension of class GraphAttributes, to store clustergraph layout ...
Declaration of class EdgeWeightedGraph.
Declaration of class GridLayout.
Stores additional attributes of a clustered graph (like layout information).
Representation of clustered graphs.
Dynamic arrays indexed with edges.
Definition EdgeArray.h:125
Class for the representation of edges.
Definition Graph_d.h:300
Stores additional attributes of a graph (like layout information).
static const long edgeDoubleWeight
Corresponds to edge attribute doubleWeight(edge).
static const long edgeIntWeight
Corresponds to edge attribute intWeight(edge).
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:521
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Definition Graph_d.h:592
Condensed settings for drawing SVGs.
Definition GraphIO.h:116
const string & fontFamily() const
Returns the default font family.
Definition GraphIO.h:145
const string & height() const
Returns the default height.
Definition GraphIO.h:151
void curviness(double value)
Sets the curviness of all edges (value ranges from 0 to 1).
Definition GraphIO.h:157
const string & width() const
Returns the default width.
Definition GraphIO.h:148
int fontSize() const
Returns the default font size (font height in pixels).
Definition GraphIO.h:139
void fontFamily(const string &fm)
Sets the default font family to fm.
Definition GraphIO.h:174
void margin(double m)
Sets the size of the margin around the drawing to m.
Definition GraphIO.h:154
bool bezierInterpolation() const
Returns whether Bézier-interpolation for curved edges is enabled.
Definition GraphIO.h:130
void height(const string &height)
Sets the height.
Definition GraphIO.h:186
double curviness() const
Returns the curviness of the edges (value ranges from 0 to 1).
Definition GraphIO.h:136
const string & fontColor() const
Returns the default font color.
Definition GraphIO.h:142
void fontSize(int fs)
Sets the default font size (font height in pixels) to fs.
Definition GraphIO.h:168
double margin() const
Returns the size of the margin around the drawing.
Definition GraphIO.h:133
void fontColor(const string &fc)
Sets the default font color to fc.
Definition GraphIO.h:171
void width(const string &width)
Sets the width.
Definition GraphIO.h:180
void bezierInterpolation(bool enable)
Enables or disables Bézier-interpolation.
Definition GraphIO.h:165
Utility class providing graph I/O in various exchange formats.
Definition GraphIO.h:50
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 bool writeTLP(const Graph &G, std::ostream &os)
Writes graph G in TLP format to output stream os.
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
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
static bool read(ClusterGraphAttributes &GA, ClusterGraph &CG, Graph &G, std::istream &is)
Reads graph G, a clustering CG of G and their attributes GA from a stream is and try to guess the con...
static bool writeDOT(const GraphAttributes &A, std::ostream &os)
Writes graph with attributes A in DOT format to output stream os.
static bool drawSVG(const GraphAttributes &A, std::ostream &os)
Definition GraphIO.h:1791
static bool writeGML(const ClusterGraphAttributes &A, std::ostream &os)
Writes graph with attributes A in GML format to output stream os.
static bool readDigraph6(Graph &G, std::istream &is, bool forceHeader=false)
Reads graph G in Digraph6 format from input stream is.
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 writeDigraph6(const Graph &G, std::ostream &os)
Writes graph G in Digraph6 format to output stream os.
static bool readDOT(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, std::istream &is)
Reads clustered graph (C, G) with attributes A in DOT format from input stream is.
bool(*)(Graph &, std::istream &) ReaderFunc
Type of simple graph reader functions working on streams.
Definition GraphIO.h:55
static bool readTsplibXml(Graph &G, std::istream &is)
Reads graph G in TsplibXml format from input stream is.
static bool readGEXF(Graph &G, std::istream &is)
Reads graph G in GEXF format from input stream is.
static bool writeGML(const ClusterGraph &C, std::ostream &os)
Writes clustered graph C in GML format to output stream os.
static bool readSTP(GraphAttributes &attr, Graph &G, std::istream &is)
Reads a graph in SteinLib format from std::istream is.
Definition GraphIO.h:1528
static bool readChaco(Graph &G, std::istream &is)
Reads graph G in Chaco format from input stream is.
static bool drawSVG(const ClusterGraphAttributes &A, const string &filename, const SVGSettings &settings=svgSettings)
Definition GraphIO.h:1810
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.
static bool writeGEXF(const ClusterGraph &C, std::ostream &os)
Writes clustered graph C in GEXF format to output stream os.
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 readRudy(Graph &G, std::istream &is)
Reads graph G in Rudy format from input stream is.
Definition GraphIO.h:912
static double & getEdgeWeightAttribute(GraphAttributes &attr, edge e)
Returns a reference to the doubleWeight()-value of attr for e.
Definition GraphIO.h:1922
static bool readDOT(ClusterGraph &C, Graph &G, std::istream &is)
Reads clustered graph (C, G) in DOT format from input stream is.
static bool writeGraphML(const ClusterGraphAttributes &A, std::ostream &os)
Writes graph with attributes A in GraphML format to output stream os.
static bool write(const GraphAttributes &GA, const string &filename, AttrWriterFunc writer=nullptr)
Writes graph G and its attributes GA to a file with name filename and infers the format to use from t...
static std::unordered_map< string, const FileType * > FILE_TYPE_MAP
Definition GraphIO.h:109
static bool writeChaco(const Graph &G, std::ostream &os)
Writes graph G in Chaco format to output stream os.
static SVGSettings svgSettings
Definition GraphIO.h:1928
static bool readGraphML(Graph &G, std::istream &is)
Reads graph G in GraphML format from input stream is.
static bool writeDL(const Graph &G, std::ostream &os)
Writes graph G in DL format to output stream os.
static bool writeGraphML(const ClusterGraph &C, std::ostream &os)
Writes clustered graph C in GraphML format to output stream os.
static bool readTLP(Graph &G, std::istream &is)
Reads graph G in TLP format from input stream is.
static bool readGEXF(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, std::istream &is)
Reads clustered graph (C, G) with attributes A in GEXF format from input stream is.
static bool readGML(GraphAttributes &A, Graph &G, std::istream &is)
Reads graph G with attributes A in GML format from input stream is.
static bool readTLP(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, std::istream &is)
Reads clustered graph (C, G) with attributes A in TLP format from input stream is.
static bool readDMF(GraphAttributes &attr, Graph &graph, std::istream &is)
Reads a maximum flow instance in DIMACS format.
Definition GraphIO.h:1640
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
static const std::vector< FileType > FILE_TYPES
Definition GraphIO.h:108
static std::ostream & indent(std::ostream &os, int depth)
Prints indentation for indentation depth to output stream os and returns os.
bool(*)(ClusterGraphAttributes &, ClusterGraph &, Graph &, std::istream &) ClusterAttrReaderFunc
Type of cluster graph attributes reader functions working on streams.
Definition GraphIO.h:74
static bool writeDOT(const ClusterGraph &C, std::ostream &os)
Writes clustered graph C in DOT format to output stream os.
static bool readMatrixMarket(Graph &G, std::istream &inStream)
Reads graph G in Matrix Market exchange format from stream inStream.
static bool readGDF(Graph &G, std::istream &is)
Reads graph G in GDF format from input stream is.
static bool readGML(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, std::istream &is)
Reads clustered graph (C, G) with attributes A in GML format from input stream is.
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
static bool writeRome(const Graph &G, std::ostream &os)
Writes graph G in Rome-Lib format to output stream os.
static bool read(Graph &G, std::istream &is)
Reads graph G from a stream is and try to guess the contained format by trying all available readers.
static char s_indentChar
Character used for indentation.
Definition GraphIO.h:1931
static bool writeTLP(const ClusterGraph &C, std::ostream &os)
Writes clustered graph C in TLP format to output stream os.
static bool write(const ClusterGraphAttributes &GA, const string &filename, ClusterAttrWriterFunc writer=nullptr)
Writes graph G, a clustering CG of G and their attributes CGA to a file with name filename and infers...
static bool drawSVG(const ClusterGraphAttributes &A, std::ostream &os, const SVGSettings &settings)
static bool read(ClusterGraph &CG, Graph &G, const string &filename, ClusterReaderFunc reader=nullptr)
Reads graph G and a clustering CG of G from a file with name filename and infers the used format from...
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.
static bool readGraphML(ClusterGraphAttributes &A, ClusterGraph &C, Graph &G, std::istream &is)
Reads clustered graph (C, G) with attributes A in GraphML format from input stream is.
bool(*)(const ClusterGraph &, std::ostream &) ClusterWriterFunc
Type of cluster graph writer functions working on streams.
Definition GraphIO.h:70
static bool writeRudy(const GraphAttributes &A, std::ostream &os)
Writes graph with edge weights stored in A in Rudy format to output stream os.
static bool readTLP(ClusterGraph &C, Graph &G, std::istream &is)
Reads clustered graph (C, G) in TLP format from input stream is.
static bool readGEXF(ClusterGraph &C, Graph &G, std::istream &is)
Reads clustered graph (C, G) in GEXF format from input stream is.
static bool readDMF(Graph &graph, std::istream &is)
Reads a maximum flow instance in DIMACS format.
Definition GraphIO.h:1678
static bool writeGraphML(const Graph &G, std::ostream &os)
Writes graph G in GraphML format to output stream os.
static void setIndentChar(char c)
Sets the indentation character to c.
Definition GraphIO.h:1852
static bool writeGraphML(const GraphAttributes &A, std::ostream &os)
Writes graph with attributes A in GraphML format to output stream os.
static bool read(GraphAttributes &GA, Graph &G, const string &filename, AttrReaderFunc reader=nullptr)
Reads graph G and its attributes GA from a file with name filename and infers the used format from th...
static long getEdgeWeightFlag()
Returns GraphAttributes::edgeIntWeight.
Definition GraphIO.h:1891
static bool writeDOT(const Graph &G, std::ostream &os)
Writes graph G in DOT format to output stream os.
static bool readSparse6(Graph &G, std::istream &is, bool forceHeader=false)
Reads graph G in Sparse6 format from input stream is.
static bool writeGML(const Graph &G, std::ostream &os)
Writes graph G in GML format to output stream os.
static bool writeDOT(const ClusterGraphAttributes &A, std::ostream &os)
Writes graph with attributes A in DOT 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's thesis from input stream is.
static bool readTLP(GraphAttributes &A, Graph &G, std::istream &is)
Reads graph G with attributes A in TLP format from input stream is.
bool(*)(const Graph &, std::ostream &) WriterFunc
Type of simple graph writer functions working on streams.
Definition GraphIO.h:58
static bool readDOT(GraphAttributes &A, Graph &G, std::istream &is)
Reads graph G with attributes A in DOT format from input stream is.
static bool read(ClusterGraphAttributes &GA, ClusterGraph &CG, Graph &G, const string &filename, ClusterAttrReaderFunc reader=nullptr)
Reads graph G, a clustering CG of G and their attributes CGA from a file with name filename and infer...
static bool writeGML(const GraphAttributes &A, std::ostream &os)
Writes graph with attributes A in GML format to output stream os.
static bool writeGEXF(const GraphAttributes &A, std::ostream &os)
Writes graph with attributes A in GEXF format to output stream os.
bool(*)(const ClusterGraphAttributes &, std::ostream &) ClusterAttrWriterFunc
Type of cluster graph attributes writer functions working on streams.
Definition GraphIO.h:77
static bool drawSVG(const GraphAttributes &A, std::ostream &os, const SVGSettings &settings)
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 read(ClusterGraph &CG, Graph &G, std::istream &is)
Reads graph G and a clustering CG of G from a stream is and try to guess the contained format by tryi...
static bool drawTikz(const ClusterGraphAttributes &A, std::ostream &os)
Draws a cluster graph from its attributes in LaTeX+TikZ format.
static Logger logger
Definition GraphIO.h:52
static bool readGraphML(GraphAttributes &A, Graph &G, std::istream &is)
Reads graph G with attributes A in GraphML format from input stream is.
static int & getEdgeWeightAttribute(GraphAttributes &attr, edge e)
Returns a reference to the intWeight()-value of attr for e.
Definition GraphIO.h:1911
static bool writeTLP(const GraphAttributes &A, std::ostream &os)
Writes graph with attributes A in TLP format to output stream os.
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 readDL(GraphAttributes &A, Graph &G, std::istream &is)
Reads graph G with attributes A in DL 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.
static bool writeLEDA(const Graph &G, std::ostream &os)
Writes graph G in LEDA graph format to output stream os.
static bool readDL(Graph &G, std::istream &is)
Reads graph G in DL format from input stream is.
static const std::unordered_map< string, const FileType * > & getFileTypeMap()
static bool readLEDA(Graph &G, std::istream &is)
Reads graph G in LEDA graph format from input stream is.
static bool writeDL(const GraphAttributes &A, std::ostream &os)
Writes graph with attributes A in DL format to output stream os.
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 readTsplibXml(GraphAttributes &GA, Graph &G, std::istream &is)
Reads graph G with attributes GA in TsplibXml format from input stream is.
static bool readRome(Graph &G, std::istream &is)
Reads graph G in Rome-Lib format from input stream is.
static bool writeGEXF(const Graph &G, std::ostream &os)
Writes graph G in GEXF format to output stream os.
static bool writeTLP(const ClusterGraphAttributes &A, std::ostream &os)
Writes graph with attributes A in TLP format to output stream os.
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.
static bool readGEXF(GraphAttributes &A, Graph &G, std::istream &is)
Reads graph G with attributes A in GEXF format from input stream is.
bool(*)(const GraphAttributes &, std::ostream &) AttrWriterFunc
Type of simple graph attributes writer functions working on streams.
Definition GraphIO.h:64
static int s_indentWidth
Number of indent characters used for indentation.
Definition GraphIO.h:1932
static bool writeGDF(const GraphAttributes &A, std::ostream &os)
Writes graph with attributes A in GDF format to output stream os.
static bool readGML(ClusterGraph &C, Graph &G, std::istream &is)
Reads clustered graph (C, G) in GML format from input stream is.
static bool drawSVG(const GraphAttributes &A, const string &filename, const SVGSettings &settings=svgSettings)
Definition GraphIO.h:1797
static bool readEdgeListSubgraph(Graph &G, List< edge > &delEdges, std::istream &is)
Reads graph G with subgraph defined by delEdges from 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 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.
static bool readDOT(Graph &G, std::istream &is)
Reads graph G in DOT format from input stream is.
static bool readGML(Graph &G, std::istream &is)
Reads graph G in GML format from input stream is.
static const FileType * getFileType(const string &filename)
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 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.
static bool readGDF(GraphAttributes &A, Graph &G, std::istream &is)
Reads graph G with attributes A in GDF format from input stream is.
static bool writeGraph6(const Graph &G, std::ostream &os)
Writes graph G in Graph6 format to output stream os.
static bool readYGraph(Graph &G, std::istream &is)
Reads graph G in Y-graph format from input stream is.
static bool writeSparse6(const Graph &G, std::ostream &os)
Writes graph G in Sparse6 format to output stream os.
static bool read(GraphAttributes &GA, Graph &G, std::istream &is)
Reads graph G and its attributes GA from a stream is and try to guess the contained format by trying ...
static bool writeGDF(const Graph &G, std::ostream &os)
Writes graph G in GDF format to output stream os.
bool(*)(GraphAttributes &, Graph &, std::istream &) AttrReaderFunc
Type of simple graph attributes reader functions working on streams.
Definition GraphIO.h:61
static bool drawSVG(const ClusterGraphAttributes &A, std::ostream &os)
Definition GraphIO.h:1806
static bool write(const ClusterGraph &CG, const string &filename, ClusterWriterFunc writer=nullptr)
Writes graph G and a clustering CG of G to a file with name filename and infers the format to use fro...
static bool drawTikz(const GraphAttributes &A, std::ostream &os)
Draws a graph from its attributes in LaTeX+TikZ format.
static void setIndentWidth(int w)
Sets the indentation width to w.
Definition GraphIO.h:1862
static bool readSTP(Graph &G, std::istream &is)
Reads a graph in SteinLib format from std::istream is.
Definition GraphIO.h:1541
static bool readGraphML(ClusterGraph &C, Graph &G, std::istream &is)
Reads clustered graph (C, G) in GraphML format from input stream is.
static char indentChar()
Returns the currently used indentation character.
Definition GraphIO.h:1843
static bool writeGEXF(const ClusterGraphAttributes &A, std::ostream &os)
Writes graph with attributes A in GEXF format to output stream os.
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
static int indentWidth()
Returns the currently used indentation width.
Definition GraphIO.h:1846
bool(*)(ClusterGraph &, Graph &, std::istream &) ClusterReaderFunc
Type of cluster graph reader functions working on streams.
Definition GraphIO.h:67
Representation of a graph's grid layout.
Definition GridLayout.h:46
Doubly linked lists (maintaining the length of the list).
Definition List.h:1435
Centralized global and local logging facility working on streams like std::cout.
Definition Logger.h:100
std::ostream & lout(Level level=Level::Default) const
stream for logging-output (local)
Definition Logger.h:142
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
Class for the representation of nodes.
Definition Graph_d.h:177
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
Definition of exception classes.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:41
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
WriterFunc writer_func
Definition GraphIO.h:83
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)
ClusterAttrReaderFunc cluster_attr_reader_func
Definition GraphIO.h:90
ReaderFunc auto_reader_func
Definition GraphIO.h:82
ClusterReaderFunc auto_cluster_reader_func
Definition GraphIO.h:88
std::vector< std::string > extensions
Definition GraphIO.h:80
FileType & replaceAutoReaders(ReaderFunc readerFunc=nullptr, AttrReaderFunc attrReaderFunc=nullptr, ClusterReaderFunc clusterReaderFunc=nullptr, ClusterAttrReaderFunc clusterAttrReaderFunc=nullptr)
ClusterWriterFunc cluster_writer_func
Definition GraphIO.h:89
ClusterAttrWriterFunc cluster_attr_writer_func
Definition GraphIO.h:92
AttrWriterFunc attr_writer_func
Definition GraphIO.h:86
ReaderFunc reader_func
Definition GraphIO.h:81
ClusterReaderFunc cluster_reader_func
Definition GraphIO.h:87
ClusterAttrReaderFunc auto_cluster_attr_reader_func
Definition GraphIO.h:91
AttrReaderFunc attr_reader_func
Definition GraphIO.h:84
AttrReaderFunc auto_attr_reader_func
Definition GraphIO.h:85