|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
49 #include <type_traits>
50 #include <unordered_map>
145 double margin()
const {
return m_margin; }
160 const string&
width()
const {
return m_width; }
163 const string&
height()
const {
return m_height; }
701 #pragma mark PMDissGraph
814 #pragma mark Digraph6
880 #pragma mark MatrixMarket
1000 #pragma mark ChallengeGraph
1036 #pragma mark GraphML
1543 return readSTP(attr, G, terminals, isTerminal, is);
1571 template<
typename T>
1576 bool res =
readSTP(attr, wG, terminals, isTerminal, is);
1577 for (
edge e : wG.edges) {
1578 wG.
setWeight(e, getEdgeWeightAttribute<T>(attr, e));
1601 std::ostream& os,
const string& comments =
"");
1615 template<
typename T>
1617 std::ostream& os,
const string& comments =
"") {
1619 for (
edge e : wG.edges) {
1620 getEdgeWeightAttribute<T>(attr, e) = wG.
weight(e);
1622 return writeSTP(attr, terminals, os, comments);
1655 return readDMF(attr, graph, sink, source, is);
1670 template<
typename T>
1674 bool result =
readDMF(attr, graph, source, sink, is);
1675 weights.
init(graph);
1677 weights[e] = getEdgeWeightAttribute<T>(attr, e);
1694 return readDMF(attr, graph, source, sink, is);
1711 const node sink, std::ostream& os);
1724 template<
typename T>
1726 const node sink, std::ostream& os) {
1729 getEdgeWeightAttribute<T>(attr, e) = weights[e];
1731 return writeDMF(attr, source, sink, os);
1734 #pragma mark TsplibXml
1801 const SVGSettings& settings);
1811 std::ofstream os(filename);
1812 return os.good() &&
drawSVG(
A, os, settings);
1816 const SVGSettings& settings);
1824 std::ofstream os(filename);
1825 return os.good() &&
drawSVG(
A, os, settings);
1890 if (value < 0 || value > 255) {
1894 setFunction(
static_cast<uint8_t
>(value));
1902 template<typename T, typename std::enable_if<std::is_integral<T>::value,
bool>
::type = 0>
1911 template<typename T, typename std::enable_if<std::is_floating_point<T>::value,
bool>
::type = 0>
1922 template<typename T, typename std::enable_if<std::is_integral<T>::value,
bool>
::type = 0>
1933 template<typename T, typename std::enable_if<std::is_floating_point<T>::value,
bool>
::type = 0>
static const long edgeIntWeight
Corresponds to edge attribute intWeight(edge).
bool(*)(const ClusterGraphAttributes &, std::ostream &) ClusterAttrWriterFunc
Type of cluster graph attributes writer functions working on streams.
The namespace for all OGDF objects.
Stores additional attributes of a graph (like layout information).
Declaration of class GraphAttributes which extends a Graph by additional attributes.
static bool readSTP(Graph &G, std::istream &is)
Reads a graph in SteinLib format from std::istream is.
static bool readGraph6(Graph &G, std::istream &is, bool forceHeader=false)
Reads graph G in Graph6 format from input stream is.
bool(*)(ClusterGraph &, Graph &, std::istream &) ClusterReaderFunc
Type of cluster graph reader functions working on streams.
static bool readChaco(Graph &G, std::istream &is)
Reads graph G in Chaco format from input stream is.
Includes declaration of graph class.
static int & getEdgeWeightAttribute(GraphAttributes &attr, edge e)
Returns a reference to the intWeight()-value of attr for e.
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 char indentChar()
Returns the currently used indentation character.
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.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
const string & fontFamily() const
Returns the default font family.
T weight(const edge e) const
std::vector< std::string > extensions
static bool writeGML(const Graph &G, std::ostream &os)
Writes graph G in GML format to output stream os.
static bool drawSVG(const GraphAttributes &A, std::ostream &os, const SVGSettings &settings)
static const FileType * getFileType(const string &filename)
ClusterAttrReaderFunc auto_cluster_attr_reader_func
static bool drawSVG(const GraphAttributes &A, std::ostream &os)
static SVGSettings svgSettings
void curviness(double value)
Sets the curviness of all edges (value ranges from 0 to 1).
static void setIndentWidth(int w)
Sets the indentation width to w.
static bool drawSVG(const ClusterGraphAttributes &A, const string &filename, const SVGSettings &settings=svgSettings)
static bool writeLEDA(const Graph &G, std::ostream &os)
Writes graph G in LEDA graph format to output stream os.
FileType & replaceAutoReaders(ReaderFunc readerFunc=nullptr, AttrReaderFunc attrReaderFunc=nullptr, ClusterReaderFunc clusterReaderFunc=nullptr, ClusterAttrReaderFunc clusterAttrReaderFunc=nullptr)
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.
bool(*)(const Graph &, std::ostream &) WriterFunc
Type of simple graph writer functions working on streams.
int fontSize() const
Returns the default font size (font height in pixels).
static bool readGML(Graph &G, std::istream &is)
Reads graph G in GML format from input stream is.
static bool readSTP(GraphAttributes &attr, Graph &G, std::istream &is)
Reads a graph in SteinLib format from std::istream is.
bool(*)(const GraphAttributes &, std::ostream &) AttrWriterFunc
Type of simple graph attributes writer functions working on streams.
static bool readRudy(Graph &G, std::istream &is)
Reads graph G in Rudy format from input stream is.
ReaderFunc auto_reader_func
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.
double margin() const
Returns the size of the margin around the drawing.
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.
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)
static const std::unordered_map< string, const FileType * > & getFileTypeMap()
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.
ClusterAttrWriterFunc cluster_attr_writer_func
static bool readYGraph(Graph &G, std::istream &is)
Reads graph G in Y-graph format from input stream is.
static bool readGraphML(Graph &G, std::istream &is)
Reads graph G in GraphML format from input stream is.
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.
void fontColor(const string &fc)
Sets the default font color to fc.
bool(*)(const ClusterGraph &, std::ostream &) ClusterWriterFunc
Type of cluster graph writer functions working on streams.
void width(const string &width)
Sets the width.
static bool readMatrixMarket(Graph &G, std::istream &inStream)
Reads graph G in Matrix Market exchange format from stream inStream.
Contains logging functionality.
static char s_indentChar
Character used for indentation.
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 readRome(Graph &G, std::istream &is)
Reads graph G in Rome-Lib format from input stream is.
static bool readDL(Graph &G, std::istream &is)
Reads graph G in DL 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.
Stores additional attributes of a clustered graph (like layout information).
static bool writeGDF(const Graph &G, std::ostream &os)
Writes graph G in GDF format to output stream os.
AttrReaderFunc attr_reader_func
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.
static bool writeDOT(const Graph &G, std::ostream &os)
Writes graph G in DOT format to output stream os.
const string & height() const
Returns the default height.
static bool readDOT(Graph &G, std::istream &is)
Reads graph G in DOT format from input stream is.
static bool readDMF(GraphAttributes &attr, Graph &graph, std::istream &is)
Reads a maximum flow instance in DIMACS format.
Condensed settings for drawing SVGs.
static bool readDigraph6(Graph &G, std::istream &is, bool forceHeader=false)
Reads graph G in Digraph6 format from input stream is.
bool(*)(ClusterGraphAttributes &, ClusterGraph &, Graph &, std::istream &) ClusterAttrReaderFunc
Type of cluster graph attributes reader functions working on streams.
Utility class providing graph I/O in various exchange formats.
static bool readEdgeListSubgraph(Graph &G, List< edge > &delEdges, std::istream &is)
Reads graph G with subgraph defined by delEdges from stream is.
static int indentWidth()
Returns the currently used indentation width.
Decralation of GraphElement and GraphList classes.
static bool writeGEXF(const Graph &G, std::ostream &os)
Writes graph G in GEXF format to output stream os.
static bool readDMF(GraphAttributes &attr, Graph &graph, node &source, node &sink, std::istream &is)
Reads a maximum flow instance in DIMACS format.
ClusterWriterFunc cluster_writer_func
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 long getEdgeWeightFlag()
Returns GraphAttributes::edgeIntWeight.
static std::ostream & indent(std::ostream &os, int depth)
Prints indentation for indentation depth to output stream os and returns os.
void margin(double m)
Sets the size of the margin around the drawing to m.
bool(*)(GraphAttributes &, Graph &, std::istream &) AttrReaderFunc
Type of simple graph attributes reader functions working on streams.
static bool readDMF(Graph &graph, EdgeArray< T > &weights, node &source, node &sink, std::istream &is)
Reads a maximum flow instance in DIMACS format.
Doubly linked lists (maintaining the length of the list).
RegisteredArray for nodes, edges and adjEntries of a graph.
AttrWriterFunc attr_writer_func
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.
Data type for general directed graphs (adjacency list representation).
const string & width() const
Returns the default width.
static bool readLEDA(Graph &G, std::istream &is)
Reads graph G in LEDA graph format from input stream 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.
static bool writeDL(const Graph &G, std::ostream &os)
Writes graph G in DL format to output stream os.
static bool writeGraph6(const Graph &G, std::ostream &os)
Writes graph G in Graph6 format to output stream os.
static bool writeChaco(const Graph &G, std::ostream &os)
Writes graph G in Chaco format to output stream os.
static bool readDMF(Graph &graph, std::istream &is)
Reads a maximum flow instance in DIMACS format.
static double & getEdgeWeightAttribute(GraphAttributes &attr, edge e)
Returns a reference to the doubleWeight()-value of attr for e.
static bool writeGraphML(const Graph &G, std::ostream &os)
Writes graph G in GraphML format to output stream os.
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
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.
void bezierInterpolation(bool enable)
Enables or disables Bézier-interpolation.
static bool drawSVG(const GraphAttributes &A, const string &filename, const SVGSettings &settings=svgSettings)
ClusterReaderFunc auto_cluster_reader_func
void fontSize(int fs)
Sets the default font size (font height in pixels) to fs.
Basic declarations, included by all source files.
static bool drawSVG(const ClusterGraphAttributes &A, std::ostream &os)
static bool readGDF(Graph &G, std::istream &is)
Reads graph G in GDF format from input stream is.
const string & fontColor() const
Returns the default font color.
static bool readGEXF(Graph &G, std::istream &is)
Reads graph G in GEXF format from input stream is.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
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.
ClusterReaderFunc cluster_reader_func
static bool writeTLP(const Graph &G, std::ostream &os)
Writes graph G in TLP format to output stream os.
static bool drawTikz(const GraphAttributes &A, std::ostream &os)
Draws a graph from its attributes in LaTeX+TikZ format.
static bool writeDigraph6(const Graph &G, std::ostream &os)
Writes graph G in Digraph6 format to output stream os.
Declares ClusterGraphAttributes, an extension of class GraphAttributes, to store clustergraph layout ...
Class for the representation of edges.
bool(*)(Graph &, std::istream &) ReaderFunc
Type of simple graph reader functions working on streams.
Derived class of GraphObserver providing additional functionality to handle clustered graphs.
Declaration of doubly linked lists and iterators.
static bool readTsplibXml(Graph &G, std::istream &is)
Reads graph G in TsplibXml format from input stream is.
double curviness() const
Returns the curviness of the edges (value ranges from 0 to 1).
void init(const Graph *base=nullptr)
Reinitializes the array. Associates the array with the matching registry of base.
static bool writeRome(const Graph &G, std::ostream &os)
Writes graph G in Rome-Lib format to output stream os.
Representation of a graph's grid layout.
static int s_indentWidth
Number of indent characters used for indentation.
bool bezierInterpolation() const
Returns whether Bézier-interpolation for curved edges is enabled.
int intWeight(edge e) const
Returns the (integer) weight of edge e.
static void setIndentChar(char c)
Sets the indentation character to c.
static const long edgeDoubleWeight
Corresponds to edge attribute doubleWeight(edge).
static const std::vector< FileType > FILE_TYPES
AttrReaderFunc auto_attr_reader_func
double doubleWeight(edge e) const
Returns the (real number) weight of edge e.
static bool writeEdgeListSubgraph(const Graph &G, const List< edge > &delEdges, std::ostream &os)
Writes graph G with subgraph defined by delEdges to stream os.
Centralized global and local logging facility working on streams like std::cout.
void setWeight(const edge e, T weight)
static std::unordered_map< string, const FileType * > FILE_TYPE_MAP
void fontFamily(const string &fm)
Sets the default font family to fm.
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...
static bool readSparse6(Graph &G, std::istream &is, bool forceHeader=false)
Reads graph G in Sparse6 format from input stream is.
Representation of clustered graphs.
Class for the representation of nodes.
static bool readTLP(Graph &G, std::istream &is)
Reads graph G in TLP 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.
void height(const string &height)
Sets the height.
ClusterAttrReaderFunc cluster_attr_reader_func
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
bool m_bezierInterpolation
std::ostream & lout(Level level=Level::Default, bool indent=true) const
stream for logging-output (local)
static bool writeSparse6(const Graph &G, std::ostream &os)
Writes graph G in Sparse6 format to output stream os.