@@ -9728,18 +9728,19 @@ PyObject *igraphmodule_Graph_write_pajek(igraphmodule_GraphObject * self,
9728
9728
PyObject *igraphmodule_Graph_write_graphml(igraphmodule_GraphObject * self,
9729
9729
PyObject * args, PyObject * kwds)
9730
9730
{
9731
- PyObject *fname = NULL;
9732
- static char *kwlist[] = { "f", NULL };
9731
+ PyObject *fname = NULL, *prefixattr_o = Py_True ;
9732
+ static char *kwlist[] = { "f", "prefixattr", NULL };
9733
9733
igraphmodule_filehandle_t fobj;
9734
9734
9735
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", kwlist, &fname))
9735
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O ", kwlist, &fname, &prefixattr_o ))
9736
9736
return NULL;
9737
9737
9738
9738
if (igraphmodule_filehandle_init(&fobj, fname, "w"))
9739
9739
return NULL;
9740
9740
9741
- if (igraph_write_graph_graphml(&self->g, igraphmodule_filehandle_get(&fobj),
9742
- /*prefixattr=*/ 1)) {
9741
+ if (igraph_write_graph_graphml(
9742
+ &self->g, igraphmodule_filehandle_get(&fobj), PyObject_IsTrue(prefixattr_o)
9743
+ )) {
9743
9744
igraphmodule_handle_igraph_error();
9744
9745
igraphmodule_filehandle_destroy(&fobj);
9745
9746
return NULL;
@@ -16930,9 +16931,13 @@ struct PyMethodDef igraphmodule_Graph_methods[] = {
16930
16931
/* interface to igraph_write_graph_edgelist */
16931
16932
{"write_graphml", (PyCFunction) igraphmodule_Graph_write_graphml,
16932
16933
METH_VARARGS | METH_KEYWORDS,
16933
- "write_graphml(f)\n--\n\n"
16934
+ "write_graphml(f, prefixattr=True )\n--\n\n"
16934
16935
"Writes the graph to a GraphML file.\n\n"
16935
16936
"@param f: the name of the file to be written or a Python file handle\n"
16937
+ "@param prefixattr: whether attribute names in the written file should be\n"
16938
+ " prefixed with C{g_}, C{v_} and C{e_} for graph, vertex and edge\n"
16939
+ " attributes, respectively. This might be needed to ensure the uniqueness\n"
16940
+ " of attribute identifiers in the written GraphML file.\n"
16936
16941
},
16937
16942
/* interface to igraph_write_graph_leda */
16938
16943
{"write_leda", (PyCFunction) igraphmodule_Graph_write_leda,
0 commit comments