--- libgexf/filewriter.cpp 2009-10-29 14:57:33 +0000 +++ libgexf/filewriter.cpp 2010-12-04 15:11:25 +0000 @@ -334,8 +334,9 @@ const t_id source_id = it->currentSource(); const t_id target_id = it->currentTarget(); const float weight = (float)it->currentProperty(EDGE_WEIGHT); + const string label = _gexf->getData().getEdgeLabel(edge_id); const t_edge_type type = (t_edge_type)it->currentProperty(EDGE_TYPE); - this->writeEdgeNode(writer, Conv::idToStr(edge_id), Conv::idToStr(source_id), Conv::idToStr(target_id), Conv::floatToStr(weight), Conv::edgeTypeToStr(type)); + this->writeEdgeNode(writer, Conv::idToStr(edge_id), Conv::idToStr(source_id), Conv::idToStr(target_id), Conv::floatToStr(weight), Conv::edgeTypeToStr(type), label); } /* Close the element named edges. */ @@ -346,7 +347,7 @@ } //----------------------------------------- -void FileWriter::writeEdgeNode(xmlTextWriterPtr writer, const std::string& edge_id, const std::string& source_id, const std::string& target_id, const std::string& weight, const std::string& type) { +void FileWriter::writeEdgeNode(xmlTextWriterPtr writer, const std::string& edge_id, const std::string& source_id, const std::string& target_id, const std::string& weight, const std::string& type, const std::string& label) { //----------------------------------------- /* Write an element named "edge" as child of edges. */ int rc = xmlTextWriterStartElement(writer, BAD_CAST "edge"); @@ -394,6 +395,12 @@ } } + /* Add an attribute with name "label" */ + rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "label", BAD_CAST label.c_str()); + if (rc < 0) { + throw FileWriterException( "Error at xmlTextWriterWriteAttribute"); + } + AttValueIter* row = _gexf->getData().getEdgeAttributeRow(Conv::strToId(edge_id)); if( row != NULL && row->hasNext() ) { this->writeAttvaluesNode(writer, EDGE, edge_id); --- libgexf/filewriter.h 2009-09-07 11:16:14 +0000 +++ libgexf/filewriter.h 2010-12-04 15:08:13 +0000 @@ -91,7 +91,7 @@ void writeNodesNode(xmlTextWriterPtr writer); void writeNodeNode(xmlTextWriterPtr writer, const std::string& node_id, const std::string& label=""); void writeEdgesNode(xmlTextWriterPtr writer); - void writeEdgeNode(xmlTextWriterPtr writer, const std::string& edge_id, const std::string& source_id, const std::string& target_id, const std::string& cardinal="1", const std::string& type="undirected"); + void writeEdgeNode(xmlTextWriterPtr writer, const std::string& edge_id, const std::string& source_id, const std::string& target_id, const std::string& cardinal="1", const std::string& type="undirected", const std::string& label=""); void writeAttributesNode(xmlTextWriterPtr writer, const std::string& element_class); void writeAttributeNode(xmlTextWriterPtr writer, const std::string& id, const std::string& title, const std::string& type, const std::string& default_value="", const std::string& options="");