@@ -9728,18 +9728,19 @@ PyObject *igraphmodule_Graph_write_pajek(igraphmodule_GraphObject * self,
97289728PyObject *igraphmodule_Graph_write_graphml(igraphmodule_GraphObject * self,
97299729 PyObject * args, PyObject * kwds)
97309730{
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 };
97339733 igraphmodule_filehandle_t fobj;
97349734
9735- if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", kwlist, &fname))
9735+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O ", kwlist, &fname, &prefixattr_o ))
97369736 return NULL;
97379737
97389738 if (igraphmodule_filehandle_init(&fobj, fname, "w"))
97399739 return NULL;
97409740
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+ )) {
97439744 igraphmodule_handle_igraph_error();
97449745 igraphmodule_filehandle_destroy(&fobj);
97459746 return NULL;
@@ -16930,9 +16931,13 @@ struct PyMethodDef igraphmodule_Graph_methods[] = {
1693016931 /* interface to igraph_write_graph_edgelist */
1693116932 {"write_graphml", (PyCFunction) igraphmodule_Graph_write_graphml,
1693216933 METH_VARARGS | METH_KEYWORDS,
16933- "write_graphml(f)\n--\n\n"
16934+ "write_graphml(f, prefixattr=True )\n--\n\n"
1693416935 "Writes the graph to a GraphML file.\n\n"
1693516936 "@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"
1693616941 },
1693716942 /* interface to igraph_write_graph_leda */
1693816943 {"write_leda", (PyCFunction) igraphmodule_Graph_write_leda,
0 commit comments