... | ... |
@@ -889,97 +889,97 @@ |
889 | 889 |
/// \relates DigraphWriter |
890 | 890 |
template <typename Digraph> |
891 | 891 |
DigraphWriter<Digraph> digraphWriter(const char* fn, |
892 | 892 |
const Digraph& digraph) { |
893 | 893 |
DigraphWriter<Digraph> tmp(fn, digraph); |
894 | 894 |
return tmp; |
895 | 895 |
} |
896 | 896 |
|
897 | 897 |
template <typename Graph> |
898 | 898 |
class GraphWriter; |
899 | 899 |
|
900 | 900 |
template <typename Graph> |
901 | 901 |
GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph); |
902 | 902 |
|
903 | 903 |
template <typename Graph> |
904 | 904 |
GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph); |
905 | 905 |
|
906 | 906 |
template <typename Graph> |
907 | 907 |
GraphWriter<Graph> graphWriter(const char *fn, const Graph& graph); |
908 | 908 |
|
909 | 909 |
/// \ingroup lemon_io |
910 | 910 |
/// |
911 | 911 |
/// \brief \ref lgf-format "LGF" writer for directed graphs |
912 | 912 |
/// |
913 | 913 |
/// This utility writes an \ref lgf-format "LGF" file. |
914 | 914 |
/// |
915 | 915 |
/// It can be used almost the same way as \c DigraphWriter. |
916 | 916 |
/// The only difference is that this class can handle edges and |
917 | 917 |
/// edge maps as well as arcs and arc maps. |
918 | 918 |
/// |
919 | 919 |
/// The arc maps are written into the file as two columns, the |
920 | 920 |
/// caption of the columns are the name of the map prefixed with \c |
921 | 921 |
/// '+' and \c '-'. The arcs are written into the \c \@attributes |
922 | 922 |
/// section as a \c '+' or a \c '-' prefix (depends on the direction |
923 | 923 |
/// of the arc) and the label of corresponding edge. |
924 | 924 |
template <typename _Graph> |
925 | 925 |
class GraphWriter { |
926 | 926 |
public: |
927 | 927 |
|
928 | 928 |
typedef _Graph Graph; |
929 | 929 |
TEMPLATE_GRAPH_TYPEDEFS(Graph); |
930 | 930 |
|
931 | 931 |
private: |
932 | 932 |
|
933 | 933 |
|
934 | 934 |
std::ostream* _os; |
935 | 935 |
bool local_os; |
936 | 936 |
|
937 |
Graph& _graph; |
|
937 |
const Graph& _graph; |
|
938 | 938 |
|
939 | 939 |
std::string _nodes_caption; |
940 | 940 |
std::string _edges_caption; |
941 | 941 |
std::string _attributes_caption; |
942 | 942 |
|
943 | 943 |
typedef std::map<Node, std::string> NodeIndex; |
944 | 944 |
NodeIndex _node_index; |
945 | 945 |
typedef std::map<Edge, std::string> EdgeIndex; |
946 | 946 |
EdgeIndex _edge_index; |
947 | 947 |
|
948 | 948 |
typedef std::vector<std::pair<std::string, |
949 | 949 |
_writer_bits::MapStorageBase<Node>* > > NodeMaps; |
950 | 950 |
NodeMaps _node_maps; |
951 | 951 |
|
952 | 952 |
typedef std::vector<std::pair<std::string, |
953 | 953 |
_writer_bits::MapStorageBase<Edge>* > >EdgeMaps; |
954 | 954 |
EdgeMaps _edge_maps; |
955 | 955 |
|
956 | 956 |
typedef std::vector<std::pair<std::string, |
957 | 957 |
_writer_bits::ValueStorageBase*> > Attributes; |
958 | 958 |
Attributes _attributes; |
959 | 959 |
|
960 | 960 |
bool _skip_nodes; |
961 | 961 |
bool _skip_edges; |
962 | 962 |
|
963 | 963 |
public: |
964 | 964 |
|
965 | 965 |
/// \brief Constructor |
966 | 966 |
/// |
967 | 967 |
/// Construct a directed graph writer, which writes to the given |
968 | 968 |
/// output stream. |
969 | 969 |
GraphWriter(std::ostream& is, const Graph& graph) |
970 | 970 |
: _os(&is), local_os(false), _graph(graph), |
971 | 971 |
_skip_nodes(false), _skip_edges(false) {} |
972 | 972 |
|
973 | 973 |
/// \brief Constructor |
974 | 974 |
/// |
975 | 975 |
/// Construct a directed graph writer, which writes to the given |
976 | 976 |
/// output file. |
977 | 977 |
GraphWriter(const std::string& fn, const Graph& graph) |
978 | 978 |
: _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph), |
979 | 979 |
_skip_nodes(false), _skip_edges(false) {} |
980 | 980 |
|
981 | 981 |
/// \brief Constructor |
982 | 982 |
/// |
983 | 983 |
/// Construct a directed graph writer, which writes to the given |
984 | 984 |
/// output file. |
985 | 985 |
GraphWriter(const char* fn, const Graph& graph) |
0 comments (0 inline)